File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -361,7 +361,9 @@ extension DatabasePool: DatabaseReader {
361
361
return try await readerPool. get { reader in
362
362
try await reader. execute { db in
363
363
defer {
364
- try ? db. commit ( ) // Ignore commit error
364
+ // Ignore commit error, but make sure we leave the transaction
365
+ try ? db. commit ( )
366
+ assert ( !db. isInsideTransaction)
365
367
}
366
368
// The block isolation comes from the DEFERRED transaction.
367
369
try db. beginTransaction ( . deferred)
@@ -385,7 +387,9 @@ extension DatabasePool: DatabaseReader {
385
387
// Second async jump because that's how `Pool.async` has to be used.
386
388
reader. async { db in
387
389
defer {
388
- try ? db. commit ( ) // Ignore commit error
390
+ // Ignore commit error, but make sure we leave the transaction
391
+ try ? db. commit ( )
392
+ assert ( !db. isInsideTransaction)
389
393
releaseReader ( . reuse)
390
394
}
391
395
do {
@@ -547,7 +551,9 @@ extension DatabasePool: DatabaseReader {
547
551
let ( reader, releaseReader) = try readerPool. get ( )
548
552
reader. async { db in
549
553
defer {
550
- try ? db. commit ( ) // Ignore commit error
554
+ // Ignore commit error, but make sure we leave the transaction
555
+ try ? db. commit ( )
556
+ assert ( !db. isInsideTransaction)
551
557
releaseReader ( . reuse)
552
558
}
553
559
do {
Original file line number Diff line number Diff line change @@ -248,8 +248,9 @@ extension DatabaseQueue: DatabaseReader {
248
248
) {
249
249
writer. async { db in
250
250
defer {
251
- // Ignore error because we can not notify it.
251
+ // Ignore commit error ( we can not notify it), but make sure we leave the transaction
252
252
try ? db. commit ( )
253
+ assert ( !db. isInsideTransaction)
253
254
try ? db. endReadOnly ( )
254
255
}
255
256
@@ -296,8 +297,9 @@ extension DatabaseQueue: DatabaseReader {
296
297
GRDBPrecondition ( !db. isInsideTransaction, " must not be called from inside a transaction. " )
297
298
298
299
defer {
299
- // Ignore error because we can not notify it.
300
+ // Ignore commit error ( we can not notify it), but make sure we leave the transaction
300
301
try ? db. commit ( )
302
+ assert ( !db. isInsideTransaction)
301
303
try ? db. endReadOnly ( )
302
304
}
303
305
Original file line number Diff line number Diff line change @@ -113,7 +113,9 @@ public final class DatabaseSnapshot {
113
113
deinit {
114
114
// Leave snapshot isolation
115
115
reader. reentrantSync { db in
116
+ // Ignore commit error (we can not notify it), but make sure we leave the transaction
116
117
try ? db. commit ( )
118
+ assert ( !db. isInsideTransaction)
117
119
}
118
120
}
119
121
You can’t perform that action at this time.
0 commit comments