]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a spurious SQLITE_CORRUPT error that could occur within a COMMIT of a
authordan <dan@noemail.net>
Tue, 2 Jan 2018 19:57:26 +0000 (19:57 +0000)
committerdan <dan@noemail.net>
Tue, 2 Jan 2018 19:57:26 +0000 (19:57 +0000)
concurrent transaction.

FossilOrigin-Name: 50c8952c92b9f0c61935fb0df04ed1426d9e266a812071b7bf5b0215c5552757

manifest
manifest.uuid
src/btree.c
test/concurrent6.test [new file with mode: 0644]

index c25d494650afe68eba28081e32f43aaf9e2e1333..77dbf33fb400fe34ea30fb0de572e0c9750a9889 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Merge\slatest\sbegin-concurrent\schanges\sinto\sthis\sbranch.
-D 2017-12-12T18:17:09.710
+C Fix\sa\sspurious\sSQLITE_CORRUPT\serror\sthat\scould\soccur\swithin\sa\sCOMMIT\sof\sa\nconcurrent\stransaction.
+D 2018-01-02T19:57:26.765
 F Makefile.in b142eb20482922153ebc77b261cdfd0a560ed05a81e9f6d9a2b0e8192922a1d2
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc a55372a22454e742ba7c8f6edf05b83213ec01125166ad7dcee0567e2f7fc81b
@@ -416,7 +416,7 @@ F src/auth.c 6277d63837357549fe14e723490d6dc1a38768d71c795c5eb5c0f8a99f918f73
 F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b
 F src/bitvec.c 8433d9e98dd6f2ea3286e0d2fe5d65de1bfc18a706486eb2026b01be066b5806
 F src/btmutex.c 0e9ce2d56159b89b9bc8e197e023ee11e39ff8ca
-F src/btree.c a41d580524a4cd9b00443b7196d298e05463f6bfcb712853db3abcddc93cf3ab
+F src/btree.c c3e15a9e5726fa3f426322cccaf9fe972dc9b3d9e07921220286f9076413f71d
 F src/btree.h feafd0647331366f4ef17f7e68597e9029f001e7ab16a125e2f176c598a7ef4a
 F src/btreeInt.h 0e0abe97427b4139092ec8782d396a4ad18566964e992c60043e370d4c86fd99
 F src/build.c f890a66f2b78cd820b21b580f37605f8dd77f19d0b35f5850a675c88a815adca
@@ -686,6 +686,7 @@ F test/concurrent2.test 9dfbeb0a323733fe1d13443371734bb94a674dbf777f464365475903
 F test/concurrent3.test f4af1cf1220908c6dd5694923621c19e999b78cd997e2646285f08a52bcb4170
 F test/concurrent4.test e0b12cd467137e50259df3b4f837507e82aaa07c35941c88664dc8ed1d089c44
 F test/concurrent5.test d5d7d9d404a9b4502464fc097c1fc5c3012bb4f1b063fae7ad707ca983fc86c5
+F test/concurrent6.test a7860e9ca13bb5fb76bcf41c5524fbfa9c37e6e258ecf84ffb5748a272488c67
 F test/conflict.test 029faa2d81a0d1cafb5f88614beb663d972c01db
 F test/conflict2.test bb0b94cf7196c64a3cbd815c66d3ee98c2fecd9c
 F test/conflict3.test a83db76a6c3503b2fa057c7bfb08c318d8a422202d8bc5b86226e078e5b49ff9
@@ -1686,7 +1687,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P bdf791f9f7f7ab4b1871e1d3a0d5edcad46fc67d7336ae7f3f7b20e69801be8e 163c870950f386f6b0bb1ff9b3886cf95ba0deed414cae75baf87621ed3528c2
-R 99497e88454df0f5b4640ad740c855cd
+P 3fde0b4d05c249b9d2a54dd721185202c353cee23c0351b634cac349dc0a7b14
+R 131f3c49cbacffd5469d66a498022e8f
 U dan
-Z 55bd54709eec1e2f156a3a0d8460b930
+Z 25c8423f0f81f25c528eab1972eef804
index dfe596be485d7045e5432d128fe58b6967a76b7b..bb2728f213db7e432dfac5596f9980b37607df91 100644 (file)
@@ -1 +1 @@
-3fde0b4d05c249b9d2a54dd721185202c353cee23c0351b634cac349dc0a7b14
\ No newline at end of file
+50c8952c92b9f0c61935fb0df04ed1426d9e266a812071b7bf5b0215c5552757
\ No newline at end of file
index e46a3f2c347db8498568324b388f1866289ac8c7..e3fd5a3928b7c889d70ff295ebf2511e2f0a96b6 100644 (file)
@@ -4179,10 +4179,12 @@ static int btreeFixUnlocked(Btree *p){
         /* The current transaction allocated pages pMap->iFirst through
         ** nPage (inclusive) at the end of the database file. Meanwhile,
         ** other transactions have allocated (iFirst..nHPage). So move
-        ** pages (iFirst..MIN(nPage,nHPage)) to (MAX(nPage,nHPage)+1).  */
+        ** pages (iFirst..MIN(nPage,nHPage)) to (MAX(nPage,nHPage)+1). */
         Pgno iLast = MIN(nPage, nHPage);    /* Last page to move */
         Pgno nCurrent;                      /* Current size of db */
+
         nCurrent = MAX(nPage, nHPage);
+        pBt->nPage = nCurrent;
         rc = btreeRelocateRange(pBt, pMap->iFirst, iLast, &nCurrent);
 
         /* There are now no collisions with the snapshot at the head of the
@@ -6127,7 +6129,7 @@ static int allocateBtreePage(
   ** stores stores the total number of pages on the freelist. */
   n = get4byte(&pPage1->aData[36]);
   testcase( n==mxPage-1 );
-  if( ISCONCURRENT==0 && n>=mxPage ){
+  if( n>=mxPage ){
     return SQLITE_CORRUPT_BKPT;
   }
 
diff --git a/test/concurrent6.test b/test/concurrent6.test
new file mode 100644 (file)
index 0000000..44718b7
--- /dev/null
@@ -0,0 +1,60 @@
+# 2017 May 26
+#
+# The author disclaims copyright to this source code.  In place of
+# a legal notice, here is a blessing:
+#
+#    May you do good and not evil.
+#    May you find forgiveness for yourself and forgive others.
+#    May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/wal_common.tcl
+set ::testprefix concurrent6
+
+ifcapable !concurrent {
+  finish_test
+  return
+}
+
+sqlite3 db2 test.db
+
+do_execsql_test 1.0 {
+  PRAGMA page_size = 1024;
+  PRAGMA journal_mode = wal;
+  CREATE TABLE t1(x);
+  CREATE TABLE t2(x);
+  CREATE TABLE t3(x);
+  CREATE TABLE t4(x);
+
+  INSERT INTO t1 VALUES(zeroblob(1500));
+} {wal}
+
+do_execsql_test -db db2 1.1 {
+  BEGIN CONCURRENT;
+    INSERT INTO t3 VALUES(zeroblob(4000));
+    DELETE FROM t1;
+}
+
+do_execsql_test 1.2 {
+  WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100) 
+  INSERT INTO t2 SELECT zeroblob(1000) FROM s;
+
+  WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100) 
+  INSERT INTO t4  SELECT zeroblob(1000) FROM s;
+
+  DELETE FROM t4;
+}
+
+do_execsql_test -db db2 1.3 {
+  COMMIT;
+}
+
+
+finish_test
+