Commit Graph
297 Commits
Author SHA1 Message Date
Gwendal Roué 46e15616a7 [BREAKING] macOS 10.15+ 2024-09-21 14:28:24 +02:00
Gwendal Roué e4a4735494 [BREAKING] tvOS 13+ 2024-09-21 13:57:35 +02:00
Gwendal Roué 8c40592955 [BREAKING] iOS 13+ 2024-09-21 13:57:23 +02:00
Gwendal Roué 2f240fd764 [SENDING REGRET] Async database access methods return Sendable results
We can not tell the compiler that we can safely return `sending` results, because fetched values are in the same region as the `db` argument, according to SE-0414 (https://github.com/swiftlang/swift-evolution/blob/main/proposals/0414-region-based-isolation.md#rules-for-merging-isolation-regions).

```
class NotSendable { init() { } }
func fetchNotSendable(_ db: Database) -> NotSendable { fatalError() }

func notOK<T>(_ make: (Database) -> sending T) { }
func ok<T>(_ make: () -> sending T) { }

func usage() {
    ok { NotSendable() }

    // Returning a task-isolated 'NotSendable' value as a 'sending' result
    // risks causing data races.
    notOK { db in fetchNotSendable(db) }
}
```

Various attempts at modifying all fetching methods so that they have a `sending` return value have failed.
2024-09-08 16:55:25 +02:00
Gwendal Roué 5f384a4b22 ValueObservation is Sendable 2024-09-08 16:17:51 +02:00
Gwendal Roué 62d96ec544 [SENDING REGRET] Async database accesses require Sendable closures
We should be able to use sending closures instead, but DispatchQueue.async does not accept sending closures yet.
2024-09-08 16:16:40 +02:00
Gwendal Roué a7a9c75185 Place @escaping before @Sendable 2024-09-08 13:41:13 +02:00
Gwendal Roué d6b91eec85 [BREAKING] DatabaseReader async methods support Task cancellation 2024-09-01 15:35:37 +02:00
Gwendal Roué fa54b74eba [BREAKING] DatabaseWriter async methods support Task cancellation 2024-09-01 15:35:37 +02:00
Gwendal Roué b587afba0e Pool is Sendable 2024-08-25 17:28:02 +02:00
Gwendal Roué e72a37d7d5 Rename LockedBox to Mutex 2024-08-25 12:40:28 +02:00
Gwendal Roué 1de32c267b [BREAKING] Remove DatabaseFuture and concurrentRead
That's one less DispatchSemaphore. We don't need this method anymore.
2024-08-25 11:07:05 +02:00
Gwendal Roué 451a9eb493 [BREAKING] Remove Configuration.defaultTransactionKind
GRDB now defaults read-only transactions to DEFERRED, and write transactions to IMMEDIATE. See https://github.com/groue/GRDB.swift/issues/1483 for some context.
2024-08-25 08:22:07 +02:00
Gwendal Roué 8caf31296f [BREAKING] Xcode 16+, Swift 6+ 2024-08-24 15:43:09 +02:00
Gwendal Roué e79b4e25db Apply Configuration.journalMode 2023-08-25 09:10:33 +01:00
László Kustra 788887a2b8 Remove selector-based NotificationCenter calls on Linux 2023-06-29 16:23:36 +02:00
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