From: drh Date: Mon, 8 Apr 2013 18:58:00 +0000 (+0000) Subject: Still more tests using mptester. Added test cases that leave rollback X-Git-Tag: version-3.7.17~101 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6adab7a1a870a1af8dfeb18b82957e8e4385b2fa;p=thirdparty%2Fsqlite.git Still more tests using mptester. Added test cases that leave rollback journals that must be recovered by other threads. FossilOrigin-Name: 437b674f00610e2b925dc00ca27b5022e3858994 --- diff --git a/manifest b/manifest index b55b1213e9..94bee9a115 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Adding\stests\sto\sthe\smptester\sscripts. -D 2013-04-08T17:57:26.382 +C Still\smore\stests\susing\smptester.\s\sAdded\stest\scases\sthat\sleave\srollback\njournals\sthat\smust\sbe\srecovered\sby\sother\sthreads. +D 2013-04-08T18:58:00.322 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 6a6a8c548822302d3a9a651f0296bbc3dad55e83 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -111,9 +111,11 @@ F mkopcodec.awk f6fccee29e68493bfd90a2e0466ede5fa94dd2fc F mkopcodeh.awk 29b84656502eee5f444c3147f331ee686956ab0e F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3f4ddeb152a4f83872f0fa7fcb48d9fd609893da -F mptest/config02.test baaee6bba0122f45c895a88c7ac8b62ff77c6b70 -F mptest/mptest.c 7048030a410707f77845c0fda9c4a223c7069e0b -F mptest/multiwrite01.test 16f9bb13640dfe1be1e544d49b16aa9e7503ae2d +F mptest/config02.test 962913ed2b537d60de4126db7fe54716865cdd22 +F mptest/crash01.test a5f31998ed48de8267d6620e8af107ec148e5f12 +F mptest/crash02.subtest c4647feafa04109e1dc60121a895b6cba8d63ceb +F mptest/mptest.c 76c8cb03f9cc91811907d8f9ccf2a5253bbb229d +F mptest/multiwrite01.test d6cb707062268e65396bd71eb53e9d5edb5519c0 F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc @@ -1048,7 +1050,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P d77407ae6a9e09dea124dd59b14fdbbc36ed3d4e -R 8e0a5a89df2079b6986569045ce512eb +P e121adceb1e267e032dcbadb74eaa692a12a65bb +R 82dd3ae164ec063cf354b1e10f2e05ba U drh -Z a3e7b3daf8fd9801ae226170daba9d61 +Z f4809a26a66812142b3835cff8ebb4b8 diff --git a/manifest.uuid b/manifest.uuid index 35124abccb..c637c165c7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e121adceb1e267e032dcbadb74eaa692a12a65bb \ No newline at end of file +437b674f00610e2b925dc00ca27b5022e3858994 \ No newline at end of file diff --git a/mptest/config02.test b/mptest/config02.test index 303a5b4d56..e25d94081e 100644 --- a/mptest/config02.test +++ b/mptest/config02.test @@ -15,6 +15,7 @@ PRAGMA page_size=512; PRAGMA mmap_limit=65536; --end --source multiwrite01.test +--source crash02.subtest PRAGMA page_size=1024; VACUUM; CREATE TABLE pgsz(taskid, sz INTEGER); @@ -34,6 +35,7 @@ CREATE TABLE pgsz(taskid, sz INTEGER); INSERT INTO pgsz VALUES(5, eval('PRAGMA page_size')); --end --source multiwrite01.test +--source crash02.subtest --wait all SELECT sz FROM pgsz; --match 1024 1024 1024 1024 1024 @@ -56,6 +58,7 @@ DELETE FROM pgsz; INSERT INTO pgsz VALUES(5, eval('PRAGMA page_size')); --end --source multiwrite01.test +--source crash02.subtest --wait all SELECT sz FROM pgsz; --match 2048 2048 2048 2048 2048 @@ -78,6 +81,7 @@ DELETE FROM pgsz; INSERT INTO pgsz VALUES(5, eval('PRAGMA page_size')); --end --source multiwrite01.test +--source crash02.subtest --wait all SELECT sz FROM pgsz; --match 8192 8192 8192 8192 8192 @@ -100,14 +104,17 @@ DELETE FROM pgsz; INSERT INTO pgsz VALUES(5, eval('PRAGMA page_size')); --end --source multiwrite01.test +--source crash02.subtest --wait all SELECT sz FROM pgsz; --match 16384 16384 16384 16384 16384 PRAGMA auto_vacuum=FULL; VACUUM; --source multiwrite01.test +--source crash02.subtest --wait all PRAGMA auto_vacuum=FULL; PRAGMA page_size=512; VACUUM; --source multiwrite01.test +--source crash02.subtest diff --git a/mptest/crash01.test b/mptest/crash01.test new file mode 100644 index 0000000000..d094d72f29 --- /dev/null +++ b/mptest/crash01.test @@ -0,0 +1,102 @@ +/* Test cases involving incomplete transactions that must be rolled back. +*/ +--task 1 + DROP TABLE IF EXISTS t1; + CREATE TABLE t1(a INTEGER PRIMARY KEY, b); + --sleep 1 + INSERT INTO t1 VALUES(1, randomblob(2000)); + INSERT INTO t1 VALUES(2, randomblob(1000)); + --sleep 1 + INSERT INTO t1 SELECT a+2, randomblob(1500) FROM t1; + INSERT INTO t1 SELECT a+4, randomblob(1500) FROM t1; + INSERT INTO t1 SELECT a+8, randomblob(1500) FROM t1; + --sleep 1 + INSERT INTO t1 SELECT a+16, randomblob(1500) FROM t1; + --sleep 1 + INSERT INTO t1 SELECT a+32, randomblob(1500) FROM t1; + SELECT count(*) FROM t1; + --match 64 + SELECT avg(length(b)) FROM t1; + --match 1500.0 + --sleep 2 + UPDATE t1 SET b='x'||a||'y'; + SELECT total(length(b)) FROM t1; + --match 247 + SELECT a FROM t1 WHERE b='x17y'; + --match 17 + CREATE INDEX t1b ON t1(b); + SELECT a FROM t1 WHERE b='x17y'; + --match 17 + SELECT a FROM t1 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5; + --match 29 28 27 26 25 +--end +--wait 1 +--task 2 + CREATE TABLE t2(a INTEGER PRIMARY KEY, b); + INSERT INTO t2 SELECT a, b FROM t1; + UPDATE t1 SET b='x'||a||'y'; + SELECT total(length(b)) FROM t2; + --match 247 + SELECT a FROM t2 WHERE b='x17y'; + --match 17 + CREATE INDEX t2b ON t2(b); + SELECT a FROM t2 WHERE b='x17y'; + --match 17 + SELECT a FROM t2 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5; + --match 29 28 27 26 25 +--end +--task 3 + CREATE TABLE t3(a INTEGER PRIMARY KEY, b); + INSERT INTO t3 SELECT a, b FROM t1; + UPDATE t1 SET b='x'||a||'y'; + SELECT total(length(b)) FROM t3; + --match 247 + SELECT a FROM t3 WHERE b='x17y'; + --match 17 + CREATE INDEX t3b ON t3(b); + SELECT a FROM t3 WHERE b='x17y'; + --match 17 + SELECT a FROM t3 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5; + --match 29 28 27 26 25 +--end +--task 4 + CREATE TABLE t4(a INTEGER PRIMARY KEY, b); + INSERT INTO t4 SELECT a, b FROM t1; + UPDATE t1 SET b='x'||a||'y'; + SELECT total(length(b)) FROM t4; + --match 247 + SELECT a FROM t4 WHERE b='x17y'; + --match 17 + CREATE INDEX t4b ON t4(b); + SELECT a FROM t4 WHERE b='x17y'; + --match 17 + SELECT a FROM t4 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5; + --match 29 28 27 26 25 +--end +--task 5 + CREATE TABLE t5(a INTEGER PRIMARY KEY, b); + INSERT INTO t5 SELECT a, b FROM t1; + UPDATE t1 SET b='x'||a||'y'; + SELECT total(length(b)) FROM t5; + --match 247 + SELECT a FROM t5 WHERE b='x17y'; + --match 17 + CREATE INDEX t5b ON t5(b); + SELECT a FROM t5 WHERE b='x17y'; + --match 17 + SELECT a FROM t5 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5; + --match 29 28 27 26 25 +--end + +--wait all +/* After the database file has been set up, run the crash2 subscript +** multiple times. */ +--source crash02.subtest +--source crash02.subtest +--source crash02.subtest +--source crash02.subtest +--source crash02.subtest +--source crash02.subtest +--source crash02.subtest +--source crash02.subtest +--source crash02.subtest diff --git a/mptest/crash02.subtest b/mptest/crash02.subtest new file mode 100644 index 0000000000..053a9faf93 --- /dev/null +++ b/mptest/crash02.subtest @@ -0,0 +1,57 @@ +/* +** This script is called from crash01.test and config02.test and perhaps other +** script. After the database file has been set up, make a big rollback +** journal in client 1, then crash client 1. +** Then in the other clients, do an integrity check. +*/ +--task 1 + --sleep 5 + --finish + PRAGMA cache_size=10; + BEGIN; + UPDATE t1 SET b=randomblob(20000); + UPDATE t2 SET b=randomblob(20000); + UPDATE t3 SET b=randomblob(20000); + UPDATE t4 SET b=randomblob(20000); + UPDATE t5 SET b=randomblob(20000); + UPDATE t1 SET b=NULL; + UPDATE t2 SET b=NULL; + UPDATE t3 SET b=NULL; + UPDATE t4 SET b=NULL; + UPDATE t5 SET b=NULL; + --print Task one crashing an incomplete transaction + --exit 1 +--end +--task 2 + SELECT count(*) FROM t1; + --match 64 + --sleep 100 + PRAGMA integrity_check; + --output + --match ok +--end +--task 3 + SELECT count(*) FROM t1; + --match 64 + --sleep 100 + PRAGMA integrity_check; + --output + --match ok +--end +--task 4 + SELECT count(*) FROM t1; + --match 64 + --sleep 100 + PRAGMA integrity_check; + --output + --match ok +--end +--task 5 + SELECT count(*) FROM t1; + --match 64 + --sleep 100 + PRAGMA integrity_check; + --output + --match ok +--end +--wait all diff --git a/mptest/mptest.c b/mptest/mptest.c index ca056f76e6..cf8eb14e1e 100644 --- a/mptest/mptest.c +++ b/mptest/mptest.c @@ -526,14 +526,14 @@ static int startScript( *pzScript = 0; g.iTimeout = 0; while(1){ - rc = trySql("BEGIN IMMEDIATE"); + rc = trySql("BEGIN EXCLUSIVE"); if( rc==SQLITE_BUSY ){ sqlite3_sleep(10); totalTime += 10; continue; } if( rc!=SQLITE_OK ){ - fatalError("%s\nBEGIN IMMEDIATE", sqlite3_errmsg(g.db)); + fatalError("in startScript: %s", sqlite3_errmsg(g.db)); } if( g.nError || g.nTest ){ runSql("UPDATE counters SET nError=nError+%d, nTest=nTest+%d", @@ -869,13 +869,23 @@ static void runScript( ** Exit this process. If N>0 then exit without shutting down ** SQLite. (In other words, simulate a crash.) */ - if( strcmp(zCmd, "exit")==0 ){ + if( strcmp(zCmd, "exit")==0 && iClient>0 ){ int rc = atoi(azArg[0]); finishScript(iClient, taskId, 1); if( rc==0 ) sqlite3_close(g.db); exit(rc); }else + /* + ** --finish + ** + ** Mark the current task as having finished, even if it is not. + ** This can be used in conjunction with --exit to simulate a crash. + */ + if( strcmp(zCmd, "finish")==0 && iClient>0 ){ + finishScript(iClient, taskId, 1); + }else + /* ** --reset ** @@ -1203,11 +1213,11 @@ int main(int argc, char **argv){ char zTaskName[50]; rc = startScript(iClient, &zScript, &taskId); if( rc==SQLITE_DONE ) break; - if( g.iTrace ) logMessage("begin task %d", taskId); sqlite3_snprintf(sizeof(zTaskName), zTaskName, "client%02d-task-%d", iClient, taskId); + if( g.iTrace ) logMessage("begin %s", zTaskName); runScript(iClient, taskId, zScript, zTaskName); - if( g.iTrace ) logMessage("end task %d", taskId); + if( g.iTrace ) logMessage("end %s", zTaskName); finishScript(iClient, taskId, 0); sqlite3_sleep(10); } diff --git a/mptest/multiwrite01.test b/mptest/multiwrite01.test index a3cfb0dbb4..dc7d62b8f9 100644 --- a/mptest/multiwrite01.test +++ b/mptest/multiwrite01.test @@ -402,3 +402,4 @@ PRAGMA integrity_check; ORDER BY t3.a LIMIT 7 --match 45 46 47 48 49 50 51 --end +--wait all