From 08756372d0ef318407d9ca9b3439c1ae7cf1f71b Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 19 Nov 2010 07:17:09 +0000 Subject: [PATCH] Add extra test cases for blocking checkpoints. FossilOrigin-Name: ac348ae25cb0239dc525bb473cc83cdb1b3de205 --- manifest | 12 ++++----- manifest.uuid | 2 +- test/wal5.test | 72 ++++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 71 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 4cb48f95f4..6055c0cab3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fixes\sfor\sSQLITE_BUSY\shandling\sin\sblocking\scheckpoint\scode. -D 2010-11-18T19:28:02 +C Add\sextra\stest\scases\sfor\sblocking\scheckpoints. +D 2010-11-19T07:17:10 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e7a59672eaeb04408d1fa8501618d7501a3c5e39 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -828,7 +828,7 @@ F test/wal.test f060cae4b2164c4375109a8f803873187234661d F test/wal2.test 894d55dda774340fe7bebe239bed9b6130ff23d7 F test/wal3.test 55529a3fbf0a04670558dbf0b06f04a2f3508db4 F test/wal4.test 3404b048fa5e10605facaf70384e6d2943412e30 -F test/wal5.test 79963972107e4cabda4c4b44a64e89c3e9af463d +F test/wal5.test b467d39f88ce0e814a3cf381f0f6a014664d2e85 F test/wal_common.tcl a98f17fba96206122eff624db0ab13ec377be4fe F test/walbak.test 4df1c7369da0301caeb9a48fa45997fd592380e4 F test/walbig.test e882bc1d014afffbfa2b6ba36e0f07d30a633ad0 @@ -888,7 +888,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P a8910e89dee326d7788b29e77820eb1e114739ca -R a15fbbfd076e96cb91858a5a2944b7af +P 4c663a4dcc77e00558edd94f58410605b95db33a +R d43362578e7138fb690b169b023fbca4 U dan -Z 77692281a1477b941972542152e8834d +Z c818aa76c45599e0e0a501a870acd353 diff --git a/manifest.uuid b/manifest.uuid index 81ad5c3317..4c59d4499f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4c663a4dcc77e00558edd94f58410605b95db33a \ No newline at end of file +ac348ae25cb0239dc525bb473cc83cdb1b3de205 \ No newline at end of file diff --git a/test/wal5.test b/test/wal5.test index ffcf044866..c2fbfdd51b 100644 --- a/test/wal5.test +++ b/test/wal5.test @@ -139,6 +139,9 @@ proc file_page_counts {} { [wal_page_count test.db2] } +# Test that executing "PRAGMA wal_checkpoint" checkpoints all attached +# databases, not just the main db. +# do_multiclient_test tn { setup_and_attach_aux do_test 2.1.$tn.1 { @@ -149,16 +152,13 @@ do_multiclient_test tn { INSERT INTO t2 VALUES(1, 2); } } {} - do_test 2.2.$tn.2 { file_page_counts } {1 5 1 5} do_test 2.1.$tn.3 { sql1 { PRAGMA wal_checkpoint } } {0 5 5} do_test 2.1.$tn.4 { file_page_counts } {2 5 2 5} } do_multiclient_test tn { - setup_and_attach_aux - do_test 2.2.$tn.1 { execsql { CREATE TABLE t1(a, b); @@ -168,7 +168,6 @@ do_multiclient_test tn { INSERT INTO t2 VALUES(3, 4); } } {} - do_test 2.2.$tn.2 { file_page_counts } {1 5 1 7} do_test 2.2.$tn.3 { sql2 { BEGIN; SELECT * FROM t1 } } {1 2} do_test 2.2.$tn.4 { sql1 { PRAGMA wal_checkpoint = RESTART } } {1 5 5} @@ -176,9 +175,7 @@ do_multiclient_test tn { } do_multiclient_test tn { - setup_and_attach_aux - do_test 2.3.$tn.1 { execsql { CREATE TABLE t1(a, b); @@ -187,17 +184,76 @@ do_multiclient_test tn { INSERT INTO t2 VALUES(1, 2); } } {} - do_test 2.3.$tn.2 { file_page_counts } {1 5 1 5} do_test 2.3.$tn.3 { sql2 { BEGIN; SELECT * FROM t1 } } {1 2} do_test 2.3.$tn.4 { sql1 { INSERT INTO t1 VALUES(3, 4) } } {} do_test 2.3.$tn.5 { sql1 { INSERT INTO t2 VALUES(3, 4) } } {} do_test 2.3.$tn.6 { file_page_counts } {1 7 1 7} - do_test 2.3.$tn.7 { sql1 { PRAGMA wal_checkpoint = FULL } } {1 7 5} do_test 2.3.$tn.8 { file_page_counts } {1 7 2 7} } +# Check that checkpoints block on the correct locks. And respond correctly +# if they cannot obtain those locks. There are three locks that a checkpoint +# may block on (in the following order): +# +# 1. The writer lock: FULL and RESTART checkpoints block until any writer +# process releases its lock. +# +# 2. Readers using part of the log file. FULL and RESTART checkpoints block +# until readers using part (but not all) of the log file have finished. +# +# 3. Readers using any of the log file. After copying data into the +# database file, RESTART checkpoints block until readers using any part +# of the log file have finished. +# +foreach {tn1 checkpoint busy_on ckpt_expected expected} { + 1 PASSIVE - {0 5 5} - + 2 TYPO - {0 5 5} - + + 3 FULL - {0 7 7} 2 + 4 FULL 1 {1 5 5} 1 + 5 FULL 2 {1 7 5} 2 + 6 FULL 3 {0 7 7} 2 + + 7 RESTART - {0 7 7} 3 + 8 RESTART 1 {1 5 5} 1 + 9 RESTART 2 {1 7 5} 2 + 10 RESTART 3 {1 7 7} 3 + +} { + do_multiclient_test tn { + setup_and_attach_aux + + proc busyhandler {x} { + set ::max_busyhandler $x + if {$::busy_on!="-" && $x==$::busy_on} { return 1 } + switch -- $x { + 1 { sql2 "COMMIT ; BEGIN ; SELECT * FROM t1" } + 2 { sql3 "COMMIT" } + 3 { sql2 "COMMIT" } + } + return 0 + } + set ::max_busyhandler - + + do_test 2.4.$tn1.$tn.1 { + sql1 { + CREATE TABLE t1(a, b); + INSERT INTO t1 VALUES(1, 2); + } + sql2 { BEGIN; INSERT INTO t1 VALUES(3, 4) } + sql3 { BEGIN; SELECT * FROM t1 } + } {1 2} + + do_test 2.4.$tn1.$tn.2 { + code1 { db busy busyhandler } + sql1 "PRAGMA wal_checkpoint = $checkpoint" + } $ckpt_expected + do_test 2.4.$tn1.$tn.3 { set ::max_busyhandler } $expected + } +} finish_test + -- 2.47.2