1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Do not fail a checkpoint just because active readers prevent backfill.

FossilOrigin-Name: 9aa4243e0cedcc9204994d04af1b2b7a80c048bd
This commit is contained in:
drh
2010-05-31 12:30:52 +00:00
parent c74c333408
commit 34116eaf6a
4 changed files with 21 additions and 26 deletions

View File

@ -571,26 +571,17 @@ foreach code [list {
} {1 2 3 4 5 6 7 8 9 10}
do_test wal-10.$tn.12 {
catchsql { PRAGMA wal_checkpoint }
} {1 {database is locked}}
} {0 {}} ;# Reader no longer block checkpoints
do_test wal-10.$tn.13 {
execsql { INSERT INTO t1 VALUES(11, 12) }
sql2 {SELECT * FROM t1}
} {1 2 3 4 5 6 7 8 9 10}
# Connection [db2] is holding a lock on a snapshot, preventing [db] from
# checkpointing the database. Add a busy-handler to [db]. If [db2] completes
# its transaction from within the busy-handler, [db] is able to complete
# the checkpoint operation.
# Writers do not block checkpoints any more either.
#
proc busyhandler x {
if {$x==4} { sql2 COMMIT }
if {$x<5} { return 0 }
return 1
}
db busy busyhandler
do_test wal-10.$tn.14 {
execsql { PRAGMA wal_checkpoint }
} {}
catchsql { PRAGMA wal_checkpoint }
} {0 {}}
# Similar to the test above. Except this time, a new read transaction is
# started (db3) while the checkpointer is waiting for an old one (db2) to
@ -598,9 +589,8 @@ foreach code [list {
# must wait until after db3 has closed the read transaction, as db3 is a
# "region D" writer.
#
db busy {}
do_test wal-10.$tn.15 {
sql2 { BEGIN; SELECT * FROM t1; }
sql2 { COMMIT; BEGIN; SELECT * FROM t1; }
} {1 2 3 4 5 6 7 8 9 10 11 12}
do_test wal-10.$tn.16 {
catchsql { PRAGMA wal_checkpoint }