Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Still more tests using mptester. Added test cases that leave rollback journals that must be recovered by other threads. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
437b674f00610e2b925dc00ca27b5022 |
User & Date: | drh 2013-04-08 18:58:00.322 |
Context
2013-04-08
| ||
19:13 | In mptester, handle startScript no-change commits using a retry rather than grabbing an exclusive transaction. (check-in: ae8bb24bfb user: drh tags: trunk) | |
18:58 | Still more tests using mptester. Added test cases that leave rollback journals that must be recovered by other threads. (check-in: 437b674f00 user: drh tags: trunk) | |
17:57 | Adding tests to the mptester scripts. (check-in: e121adceb1 user: drh tags: trunk) | |
Changes
Changes to mptest/config02.test.
︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | --task 3 PRAGMA mmap_limit=8192; --end --task 4 PRAGMA mmap_limit=65536; --end --source multiwrite01.test PRAGMA page_size=1024; VACUUM; CREATE TABLE pgsz(taskid, sz INTEGER); --task 1 INSERT INTO pgsz VALUES(1, eval('PRAGMA page_size')); --end --task 2 INSERT INTO pgsz VALUES(2, eval('PRAGMA page_size')); --end --task 3 INSERT INTO pgsz VALUES(3, eval('PRAGMA page_size')); --end --task 4 INSERT INTO pgsz VALUES(4, eval('PRAGMA page_size')); --end --task 5 INSERT INTO pgsz VALUES(5, eval('PRAGMA page_size')); --end --source multiwrite01.test --wait all SELECT sz FROM pgsz; --match 1024 1024 1024 1024 1024 PRAGMA page_size=2048; VACUUM; DELETE FROM pgsz; --task 1 | > > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | --task 3 PRAGMA mmap_limit=8192; --end --task 4 PRAGMA mmap_limit=65536; --end --source multiwrite01.test --source crash02.subtest PRAGMA page_size=1024; VACUUM; CREATE TABLE pgsz(taskid, sz INTEGER); --task 1 INSERT INTO pgsz VALUES(1, eval('PRAGMA page_size')); --end --task 2 INSERT INTO pgsz VALUES(2, eval('PRAGMA page_size')); --end --task 3 INSERT INTO pgsz VALUES(3, eval('PRAGMA page_size')); --end --task 4 INSERT INTO pgsz VALUES(4, eval('PRAGMA page_size')); --end --task 5 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 PRAGMA page_size=2048; VACUUM; DELETE FROM pgsz; --task 1 |
︙ | ︙ | |||
52 53 54 55 56 57 58 59 60 61 62 63 64 65 | --task 4 INSERT INTO pgsz VALUES(4, eval('PRAGMA page_size')); --end --task 5 INSERT INTO pgsz VALUES(5, eval('PRAGMA page_size')); --end --source multiwrite01.test --wait all SELECT sz FROM pgsz; --match 2048 2048 2048 2048 2048 PRAGMA page_size=8192; VACUUM; DELETE FROM pgsz; --task 1 | > | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | --task 4 INSERT INTO pgsz VALUES(4, eval('PRAGMA page_size')); --end --task 5 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 PRAGMA page_size=8192; VACUUM; DELETE FROM pgsz; --task 1 |
︙ | ︙ | |||
74 75 76 77 78 79 80 81 82 83 84 85 86 87 | --task 4 INSERT INTO pgsz VALUES(4, eval('PRAGMA page_size')); --end --task 5 INSERT INTO pgsz VALUES(5, eval('PRAGMA page_size')); --end --source multiwrite01.test --wait all SELECT sz FROM pgsz; --match 8192 8192 8192 8192 8192 PRAGMA page_size=16384; VACUUM; DELETE FROM pgsz; --task 1 | > | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | --task 4 INSERT INTO pgsz VALUES(4, eval('PRAGMA page_size')); --end --task 5 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 PRAGMA page_size=16384; VACUUM; DELETE FROM pgsz; --task 1 |
︙ | ︙ | |||
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | --task 4 INSERT INTO pgsz VALUES(4, eval('PRAGMA page_size')); --end --task 5 INSERT INTO pgsz VALUES(5, eval('PRAGMA page_size')); --end --source multiwrite01.test --wait all SELECT sz FROM pgsz; --match 16384 16384 16384 16384 16384 PRAGMA auto_vacuum=FULL; VACUUM; --source multiwrite01.test --wait all PRAGMA auto_vacuum=FULL; PRAGMA page_size=512; VACUUM; --source multiwrite01.test | > > > | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | --task 4 INSERT INTO pgsz VALUES(4, eval('PRAGMA page_size')); --end --task 5 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 |
Added mptest/crash01.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 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 |
Added mptest/crash02.subtest.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 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 |
Changes to mptest/mptest.c.
︙ | ︙ | |||
522 523 524 525 526 527 528 | int taskId; int rc; int totalTime = 0; *pzScript = 0; g.iTimeout = 0; while(1){ | | | | 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 | int taskId; int rc; int totalTime = 0; *pzScript = 0; g.iTimeout = 0; while(1){ rc = trySql("BEGIN EXCLUSIVE"); if( rc==SQLITE_BUSY ){ sqlite3_sleep(10); totalTime += 10; continue; } if( rc!=SQLITE_OK ){ fatalError("in startScript: %s", sqlite3_errmsg(g.db)); } if( g.nError || g.nTest ){ runSql("UPDATE counters SET nError=nError+%d, nTest=nTest+%d", g.nError, g.nTest); g.nError = 0; g.nTest = 0; } |
︙ | ︙ | |||
865 866 867 868 869 870 871 | /* ** --exit N ** ** Exit this process. If N>0 then exit without shutting down ** SQLite. (In other words, simulate a crash.) */ | | > > > > > > > > > > | 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 | /* ** --exit N ** ** Exit this process. If N>0 then exit without shutting down ** SQLite. (In other words, simulate a crash.) */ 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 ** ** Reset accumulated results back to an empty string */ if( strcmp(zCmd, "reset")==0 ){ stringReset(&sResult); |
︙ | ︙ | |||
1199 1200 1201 1202 1203 1204 1205 | if( iClient>0 ){ if( n>0 ) unrecognizedArguments(argv[0], n, argv+2); if( g.iTrace ) logMessage("start-client"); while(1){ char zTaskName[50]; rc = startScript(iClient, &zScript, &taskId); if( rc==SQLITE_DONE ) break; | < > | | 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | if( iClient>0 ){ if( n>0 ) unrecognizedArguments(argv[0], n, argv+2); if( g.iTrace ) logMessage("start-client"); while(1){ char zTaskName[50]; rc = startScript(iClient, &zScript, &taskId); if( rc==SQLITE_DONE ) break; 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 %s", zTaskName); finishScript(iClient, taskId, 0); sqlite3_sleep(10); } if( g.iTrace ) logMessage("end-client"); }else{ sqlite3_stmt *pStmt; int iTimeout; |
︙ | ︙ |
Changes to mptest/multiwrite01.test.
︙ | ︙ | |||
398 399 400 401 402 403 404 | ORDER BY t1.a LIMIT 4 --match 33 34 35 36 SELECT t3.a FROM t3, t4 WHERE t4.b GLOB 'x4?y' AND t3.b=('x'||(t4.a+5)||'y') ORDER BY t3.a LIMIT 7 --match 45 46 47 48 49 50 51 --end | > | 398 399 400 401 402 403 404 405 | ORDER BY t1.a LIMIT 4 --match 33 34 35 36 SELECT t3.a FROM t3, t4 WHERE t4.b GLOB 'x4?y' AND t3.b=('x'||(t4.a+5)||'y') ORDER BY t3.a LIMIT 7 --match 45 46 47 48 49 50 51 --end --wait all |