diff --git a/CHANGELOG.md b/CHANGELOG.md index 07776bd..4c2fe61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## Unreleased +## 1.16.1 * Fix a re-query storm on databases opened at an absolute path (App Group container). The cross-process change notification carried no payload, so every process (including the one @@ -9,6 +9,7 @@ permanent loop that pinned the CPU. Processes now exchange the concrete changed tables through a local `ps_swift_updates` table, so each process ignores its own changes and only wakes the queries whose tables actually changed. +* Update PowerSync SQLite core extension to version 0.5.3, improving internal error messages. ## 1.16.0 diff --git a/Package.resolved b/Package.resolved index e0388e1..14f315d 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "fbf9e96a3f709e253cd88e4be1fe05e3acbefdcbf7e4270db958841f93441d04", + "originHash" : "64a7ed7052f52645cc4259e052a0a9df211bc9df8b89ddfca357d89300cc6e6d", "pins" : [ { "identity" : "csqlite", @@ -24,8 +24,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/powersync-ja/powersync-sqlite-core-swift.git", "state" : { - "revision" : "dba41dd6d408b5e221d364dc7032ade14c90d023", - "version" : "0.5.2" + "revision" : "0302873677f07039d5e2fc4d1aefdf093e8e6292", + "version" : "0.5.3" } }, { diff --git a/Package.swift b/Package.swift index 335198f..5ebceb9 100644 --- a/Package.swift +++ b/Package.swift @@ -26,7 +26,7 @@ if let corePath = localCoreExtension { conditionalDependencies.append( .package( url: "https://github.com/powersync-ja/powersync-sqlite-core-swift.git", - exact: "0.5.2", + exact: "0.5.3", )) } diff --git a/Sources/PowerSync/CurrentVersion.swift b/Sources/PowerSync/CurrentVersion.swift index 0bc05b8..350972f 100644 --- a/Sources/PowerSync/CurrentVersion.swift +++ b/Sources/PowerSync/CurrentVersion.swift @@ -1,2 +1,2 @@ // The current version of the PowerSync Swift SDK. This should be updated to the latest version in `CHANGELOG.md` when a new version is released. -let libraryVersion = "1.16.0" +let libraryVersion = "1.16.1" diff --git a/Sources/PowerSync/Implementation/AsyncConnectionPool.swift b/Sources/PowerSync/Implementation/AsyncConnectionPool.swift index f199e1b..50761e1 100644 --- a/Sources/PowerSync/Implementation/AsyncConnectionPool.swift +++ b/Sources/PowerSync/Implementation/AsyncConnectionPool.swift @@ -233,14 +233,21 @@ final class AsyncConnectionPool: SQLiteConnectionPoolProtocol { func write(onConnection: @escaping @Sendable (any SQLiteConnectionLease) throws -> T) async throws -> T { let pool = try await obtainInner() return try await pool.write { connection in - try await runBlocking { try onConnection(connection) } + try await runBlocking { + defer { pool.dispatchWrites(lease: connection) } + return try onConnection(connection) + } } } func withAllConnections(onConnection: @escaping @Sendable (any SQLiteConnectionLease, [any SQLiteConnectionLease]) throws -> T) async throws -> T { let pool = try await obtainInner() return try await pool.withAllConnections { writer, readers in - try await runBlocking { try onConnection(writer, readers) } + try await runBlocking { + defer { pool.dispatchWrites(lease: writer) } + + return try onConnection(writer, readers) + } } } diff --git a/Sources/PowerSync/Implementation/sqlite3/NativeConnectionPool.swift b/Sources/PowerSync/Implementation/sqlite3/NativeConnectionPool.swift index ce6c7a5..b11a0e3 100644 --- a/Sources/PowerSync/Implementation/sqlite3/NativeConnectionPool.swift +++ b/Sources/PowerSync/Implementation/sqlite3/NativeConnectionPool.swift @@ -42,7 +42,10 @@ final class NativeConnectionPool: Sendable { self.updateLog = updateLog } - private func dispatchWrites(lease: NativeConnectionLease) { + /// Reads outstanding changes and records them for other processes. + /// + /// Recording them for other processes might write, so this should be called on a background thread only. + func dispatchWrites(lease: NativeConnectionLease) { do { try lease.withIterator(sql: "SELECT powersync_update_hooks('get')", parameters: []) { rows in guard var affectedTables = try rows.next(callback: { @@ -79,7 +82,6 @@ final class NativeConnectionPool: Sendable { func write(onConnection: (NativeConnectionLease) async throws -> T) async throws -> T { let connection = try await writer.acquire(count: 1) let lease = try connection.acquiredItems[0].asLease() - defer { dispatchWrites(lease: lease) } let result = try await onConnection(lease) return result } @@ -87,7 +89,6 @@ final class NativeConnectionPool: Sendable { func withAllConnections(onConnection: (NativeConnectionLease, [NativeConnectionLease]) async throws -> T) async throws -> T { let write = try await writer.acquire(count: 1) let writeLease = try write.acquiredItems[0].asLease() - defer { dispatchWrites(lease: writeLease) } let result: T if let readers {