Commit Graph
281 Commits
Author SHA1 Message Date
Gwendal Roué 63d360053b Fix typo and obsolete comments 2023-06-02 10:20:42 +02:00
Gwendal Roué dc440d5a8f Fix failing tests for non-empty wal files on DatabasePool creation 2023-06-02 09:44:18 +02:00
Gwendal Roué 73b279b5c1 Document methods that fail if the wal file is missing or truncated 2023-06-01 19:15:21 +02:00
Gwendal Roué cedcfbe330 Mark opportunities for snapshot creation failure (including #1383) 2023-06-01 17:26:04 +02:00
Gwendal Roué 5d9b9edfe1 Fix asyncWALSnapshotTransaction usage.
We must use its result asynchronously.
2023-03-19 12:39:48 +01:00
Gwendal Roué 449c243a36 Rename persistentReaderConnections to dbConfiguration.persistentReadOnlyConnections 2023-03-18 11:08:56 +01:00
Gwendal Roué 063877d49c Configuration.persistentReaderConnections 2023-03-17 13:52:29 +01:00
Gwendal Roué 0a544dc0d2 Cleanup relationships between SerializedDatabase, WALSnapshotTransaction, and DatabasePool
SerializedDatabase hides its allowsUnsafeTransactions property, and makes it thread-safe by protecting it inside its serialized dispatch queue.

WALSnapshotTransaction always notifies when the reader connection is no longer used, and reuses the "isInsideTransaction" wording.
2023-03-17 13:52:29 +01:00
Gwendal Roué e66dfacab8 WALSnapshotTransaction 2023-03-17 13:52:29 +01:00
Gwendal Roué 6d392f0a87 Use DatabaseError.connectionIsClosed() where appropriate 2023-03-16 13:44:08 +01:00
baegteun 557ad3d3d3 OS X -> macOS in Remake or CHANGELOG.md 2023-01-14 11:43:27 +09:00
Gwendal Roué 0dd17a9a16 Turn ValueObservationScheduler into a protocol 2022-12-29 12:38:06 +01:00
Gwendal Roué 2c5a86479a DocC: Transactions and Savepoints 2022-12-17 10:11:36 +01:00
Gwendal Roué 10596e17bf Cleanup snapshot configurations 2022-11-23 19:42:12 +01:00
Gwendal Roué 0ba3dff901 Rewrite availability check for WAL snapshots
Also, enable WAL snapshots with SQLCipher, if SQLITE_ENABLE_SNAPSHOT is set.
2022-11-18 13:33:28 +01:00
Gwendal Roué 9b663e3bcc Pool can discard elements after use 2022-11-18 08:52:52 +01:00
Gwendal Roué 12d656d3a1 Let SQLite check if DatabaseSnapshotPool can be created 2022-11-17 20:01:17 +01:00
Gwendal Roué 0bc49460d7 DatabaseSnapshotPool uses its own pool of connections
In the previous implementation, the snapshot pool would use the same reader connections as the database pool. This would create problem with reentrant reads. Let's make things simple, and not share any database connection.
2022-11-17 18:36:17 +01:00
Gwendal Roué c23b93d71b Document that reentrant database accesses use the current database connection when possible 2022-11-14 18:38:33 +01:00
Gwendal Roué b8bc8273a9 Turn snapshot tokens into a proper reader: DatabaseSnapshotPool 2022-11-14 18:22:13 +01:00
Gwendal Roué eaf8dc239a Simplify WALSnapshotToken creation 2022-11-14 10:39:48 +01:00
Gwendal Roué a71eb3d662 Introduce WALSnapshotToken 2022-11-13 18:28:54 +01:00
Gwendal Roué 997d6cb677 DatabaseSnapshot does not require the WAL mode
One can create a snapshot from a read-only pool on a non-WAL database, and that's OK. The snaphost still sees an unchanging database content (but other connections can't write).
2022-11-13 10:54:40 +01:00
Gwendal Roué 85b2e113b2 Relocate DatabaseSnapshot documentation 2022-11-09 17:16:03 +01:00
Gwendal Roué c5a0598cea DocC: Concurrency Guides 2022-11-09 13:22:53 +01:00
Gwendal Roué 71880a9b8e Enhance Documentation 2022-11-09 13:20:08 +01:00
Gwendal Roué 1818534513 DocC 2022-11-06 16:02:36 +01:00
Gwendal Roué 33a039717c Refer to UIApplication notifications by their names
It looks like FB9801372 was fixed
2022-08-21 21:22:34 +02:00
Gwendal Roué a9fcf1b9c1 SE-0335, SE-0341, SE-0346, SE-0352, SE-0358: some, any, primary associated types 2022-08-21 21:22:34 +02:00
Gwendal Roué dd55175978 SE-0345: if let x { }
https://github.com/apple/swift-evolution/blob/main/proposals/0345-if-let-shorthand.md
2022-08-21 21:22:34 +02:00
Gwendal Roué 6f0d45eedb BREAKING: throwing DatabaseWriter.barrierWriteWithoutTransaction
It used to be rethrowing, but it was then unable to deal with closed databases.

The async version is modified accordingly: it accepts a Result<Database, Error>, instead of a raw Database.

DatabaseMigrator.asyncMigrate is impacted as well: it accepts a Result<Database, Error>, instead of a (Database, Error?) tuple.
2022-08-21 19:21:57 +02:00
Gwendal Roué 6da7d47394 Swift 5.7 required: Remove compiler checks 2022-08-21 19:21:57 +02:00
Gwendal Roué c1e752132c Document why DatabasePool.releaseMemory() needs a barrier 2022-07-09 14:28:09 +02:00
Gwendal Roué 07eaeee123 automaticMemoryManagement tests check for actual connection closing 2022-07-09 13:39:39 +02:00
Gwendal Roué d72b7109ad DatabasePool automatic memory management no longer uses any reader barrier
This fixes the failing `testDatabasePoolDoesNotPreventConcurrentReadsOnPressureEvent` test
2022-07-09 13:39:11 +02:00
Gwendal Roué e1a63a4c05 Introduce DatabasePool.releaseMemoryEventually 2022-07-09 13:33:01 +02:00
George Nachman bbe94a9607 Make memory management optional.
Memory management may not be desirable for all
users of GRDB. `DatabasePool.releaseMemory`
creates a barrier which may cause normally fast
readers to block for a long time. If this is not a
desirable tradeoff, the new
`automaticMemoryManagement` flag in
`Configuration` allows you to disable this feature
of GRDB.
2022-07-05 15:27:55 -07:00
Gwendal Roué 952ee0a137 Rename Pool.async to asyncGet 2022-05-25 17:25:43 +02:00
Gwendal Roué ee92db9d6f Pool has a QoS 2022-05-25 17:21:50 +02:00
Gwendal Roué 9ed309b470 Fix failing tests for number of threads created by DatabasePool 2022-05-24 19:31:22 +02:00
Gwendal Roué 209192d3a5 Require Swift 5.6 Compiler for Concurrency Support 2022-04-13 23:07:33 +02:00
Gwendal Roué 6ab3fea8fb Refactor ValueObservation 2022-03-17 18:44:30 +01:00
Gwendal Roué 287ceb8b07 Documentation & cleanup 2022-03-17 18:44:30 +01:00
Gwendal Roué 09f7d4d952 Complete #1161 2022-01-30 15:27:11 +01:00
Gwendal Roué ed4471c5b9 Configuration.writeTargetQueue 2022-01-29 17:45:21 +01:00
Gwendal Roué 09922c34ff Code formatting 2022-01-23 12:24:34 +01:00
Gwendal Roué 1b62e06c4a Expose Sendable conformance to Swift 5.5
But async apis are still only exposed to Swift 5.5.2.

Sendable conformances are helpful for users of Xcode < 13.2.
2021-12-10 08:08:47 +01:00
Gwendal Roué 01f4c04c4d DatabaseReader is Sendable 2021-12-08 18:12:28 +01:00
Gwendal Roué 33d9ca0e97 UIApplication notification names are isolated to @MainActor
I believe this is incorrect: FB9801372 (UIApplication.didReceiveMemoryWarningNotification should not be declared @MainActor)

Meanwhile, just use the string version.

A workaround based on a MainActor-isolated task can't work due to conflict between compiler version and minimum iOS target:

    #if compiler(>=5.5) && canImport(_Concurrency)
    if #available(...) { // Check for availability of concurrency runtime
        Task { @MainActor [weak self] in
            NotificationCenter.default.addObserver(..., name: UIApplication.didReceiveMemoryWarningNotification, object: nil)
        }
    } else {
        // IMPOSSIBLE CASE: No access to Task, no access to notification names
    }
    #else
    NotificationCenter.default.addObserver(..., name: UIApplication.didReceiveMemoryWarningNotification, object: nil)
    #endif
2021-12-08 12:48:19 +01:00
Gwendal Roué 6ec3ebc398 Merge branch 'development' into dev/async 2021-12-06 18:04:35 +01:00