From: drh Date: Tue, 15 Aug 2017 01:07:03 +0000 (+0000) Subject: Fix a problem allowing a conflicting transaction to be committed in the case X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=35d7519d95e20a9357c6bbe40ffb8c16b4b93bdf;p=thirdparty%2Fsqlite.git Fix a problem allowing a conflicting transaction to be committed in the case where more than one 32KB shared-memory page has been written to since the transaction was started. FossilOrigin-Name: 346a710da4b50c9eaf327a4960174ec1f79adea0d41cd0a1c43ef82a0ba05ad7 --- diff --git a/manifest b/manifest index a85bd5c4b6..108fb6f131 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\sfix\sto\sthe\sconcurrent.test\smodule\sso\sthat\sit\sworks\son\swindows. -D 2017-07-20T19:28:49.858 +C Fix\sa\sproblem\sallowing\sa\sconflicting\stransaction\sto\sbe\scommitted\sin\sthe\scase\nwhere\smore\sthan\sone\s32KB\sshared-memory\spage\shas\sbeen\swritten\sto\ssince\sthe\ntransaction\swas\sstarted. +D 2017-08-15T01:07:03.227 F Makefile.in d9873c9925917cca9990ee24be17eb9613a668012c85a343aef7e5536ae266e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 02b469e9dcd5b7ee63fc1fb05babc174260ee4cfa4e0ef2e48c3c6801567a016 @@ -535,7 +535,7 @@ F src/vdbesort.c f512c68d0bf7e0105316a5594c4329358c8ee9cae3b25138df041d97516c037 F src/vdbetrace.c 41963d5376f0349842b5fc4aaaaacd7d9cdc0834 F src/vtab.c 35b9bdc2b41de32a417141d12097bcc4e29a77ed7cdb8f836d1d2305d946b61b F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 -F src/wal.c 57c8c0720420b5b4a4301b263f3cb09f68cf4cd2240f4473de0910b91de03923 +F src/wal.c ab94c3cc7bfe006c424b5f5945ad8285ffcda36222f0d40048d46bafb43dab69 F src/wal.h 1ea51dc499d6451529b822a8aaac053eafeef10b7fd9e5a4c9cc413182be429f F src/walker.c a7ca64ce08a83a20d32186fbe06bca9234e348cfcf07959ee322fdc3e8a6173a F src/where.c cbe8ddffbcec7ce86f7a800fe8fd10aee412c76c87e0dd3732a1682e68d74cd9 @@ -659,7 +659,7 @@ F test/collateB.test 1e68906951b846570f29f20102ed91d29e634854ee47454d725f2151eca F test/colmeta.test 2c765ea61ee37bc43bbe6d6047f89004e6508eb1 F test/colname.test 08948a4809d22817e0e5de89c7c0a8bd90cb551b F test/concfault.test 500f17c3fcfe7705114422bcc6ddd3c740001a43 -F test/concurrent.test 75977c464f9613045dfa45eb9871aca0c51c2d67a6c89ccd19d47a88c5168cfe +F test/concurrent.test f91ab1933beee68b5dbe7a784ed147d2ad190c1b84425e3ea84aefe14f7d1151 F test/concurrent2.test 9dfbeb0a323733fe1d13443371734bb94a674dbf777f464365475903873111f8 F test/concurrent3.test f4af1cf1220908c6dd5694923621c19e999b78cd997e2646285f08a52bcb4170 F test/concurrent4.test 653de3066911acfb9dcf3802bf4f1981b392b86c11f75e2c38ed1abfdd162293 @@ -1648,7 +1648,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 44c760d150b494ddd88382360cfcc4734fec936ed620f88b9df33ea7215c2fc2 -R e43e51f268de0c519f41dfe98cdb868f +P 58553d61d199477f88ea9b45055ddaf821eca2aff1bf67c7d81fa80b23c2575a +Q +38dd9b50fe260d853cbc2551bc1bb60ddf5752f0456e0da3afe4cbf728c891d8 +R e391e5c87b32637ec91c18d3a8b7747a +T *branch * begin-concurrent-branch-3.19 +T *sym-begin-concurrent-branch-3.19 * +T -sym-begin-concurrent * U drh -Z 893b46e0693cb4cb333312e0b8e9a7df +Z 16464f14c1419bb32c43d197a1db0964 diff --git a/manifest.uuid b/manifest.uuid index c116e6c3aa..983bdb244a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -58553d61d199477f88ea9b45055ddaf821eca2aff1bf67c7d81fa80b23c2575a \ No newline at end of file +346a710da4b50c9eaf327a4960174ec1f79adea0d41cd0a1c43ef82a0ba05ad7 \ No newline at end of file diff --git a/src/wal.c b/src/wal.c index 25df6f3acf..1e0b6f98bc 100644 --- a/src/wal.c +++ b/src/wal.c @@ -2900,11 +2900,10 @@ int sqlite3WalLockForCommit( rc = walHashGet(pWal, iHash, &aHash, &aPgno, &iZero); if( rc==SQLITE_OK ){ u32 i, iMin, iMax; - assert( iFirst >= iZero ); - iMin = (iFirst - iZero); + assert( head.mxFrame>=iZero ); + iMin = (iZero >= iFirst) ? 1 : (iFirst - iZero); iMax = (iHash==0) ? HASHTABLE_NPAGE_ONE : HASHTABLE_NPAGE; - if( iMin<1 ) iMin = 1; - if( iMax>head.mxFrame ) iMax = head.mxFrame; + if( iMax>(head.mxFrame-iZero) ) iMax = (head.mxFrame-iZero); for(i=iMin; rc==SQLITE_OK && i<=iMax; i++){ PgHdr *pPg; if( aPgno[i]==1 ){ diff --git a/test/concurrent.test b/test/concurrent.test index 8b05668382..f18d9d8922 100644 --- a/test/concurrent.test +++ b/test/concurrent.test @@ -558,4 +558,63 @@ do_multiclient_test tn { } {1 {database is locked}} } +do_multiclient_test tn { + do_test 7.$tn.1 { + sql1 { + PRAGMA journal_mode = wal; + CREATE TABLE t1(a INTEGER PRIMARY KEY, b); + WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<100) + INSERT INTO t1 SELECT NULL, randomblob(400) FROM s; + + CREATE TABLE t2(a INTEGER PRIMARY KEY, b); + WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<50000) + INSERT INTO t2 SELECT NULL, randomblob(400) FROM s; + + CREATE TABLE t3(a INTEGER PRIMARY KEY, b); + WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<100) + INSERT INTO t3 SELECT NULL, randomblob(400) FROM s; + + CREATE TABLE t4(a INTEGER PRIMARY KEY, b); + + PRAGMA wal_checkpoint; + } + set {} {} + } {} + + do_test 7.$tn.2 { + sql2 { + BEGIN CONCURRENT; + SELECT * FROM t1; + INSERT INTO t4 VALUES(1, 2); + } + set {} {} + } {} + + do_test 7.$tn.3 { + sql3 { + BEGIN CONCURRENT; + SELECT * FROM t3; + INSERT INTO t4 VALUES(1, 2); + } + set {} {} + } {} + + do_test 7.$tn.4 { + sql1 { + UPDATE t1 SET b=randomblob(400); + UPDATE t2 SET b=randomblob(400); + UPDATE t3 SET b=randomblob(400); + } + } {} + + do_test 7.$tn.5 { + csql2 { COMMIT } + } {1 {database is locked}} + + do_test 7.$tn.6 { + csql3 { COMMIT } + } {1 {database is locked}} + +} + finish_test