]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
If an OOM error occurs just after obtaining a shared lock on the database file, relea...
authordanielk1977 <danielk1977@noemail.net>
Mon, 22 Jun 2009 05:43:24 +0000 (05:43 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Mon, 22 Jun 2009 05:43:24 +0000 (05:43 +0000)
FossilOrigin-Name: 971a9650f66f079630489c34e40003eee97d1683

manifest
manifest.uuid
src/pager.c
test/malloc.test

index 2a0f95b280df081cbfcf67dd83191063a2c3675f..c0694546706ff53d432edf2f48316c6cd583e145 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Simplifications\sto\svdbe.c\sin\ssupport\sof\scoverage\stesting.\s(CVS\s6794)
-D 2009-06-22T00:55:31
+C If\san\sOOM\serror\soccurs\sjust\safter\sobtaining\sa\sshared\slock\son\sthe\sdatabase\sfile,\srelease\sthe\slock\sbefore\sreturning.\s(CVS\s6795)
+D 2009-06-22T05:43:24
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 8b8fb7823264331210cddf103831816c286ba446
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -146,7 +146,7 @@ F src/os_common.h 8c61457df58f1a4bd5f5adc3e90e01b37bf7afbc
 F src/os_os2.c bed77dc26e3a95ce4a204936b9a1ca6fe612fcc5
 F src/os_unix.c b64129c296e480c2827606e206ea51bb30904626
 F src/os_win.c 725c38a524d168ce280446ad8761d731bc516405
-F src/pager.c 2fc3693e83aff0864cd09c1e9e6f9825c372ff5b
+F src/pager.c 85cb38f0403881f827c30384c51a7a6e54c6d457
 F src/pager.h 5aec418bf99f568b92ae82816a1463400513726d
 F src/parse.y b6e99f4208a34eb83c62f20dd67f8d9058e86768
 F src/pcache.c 395f752a13574120bd7513a400ba02a265aaa76d
@@ -445,7 +445,7 @@ F test/lock6.test 862aa71e97b288d6b3f92ba3313f51bd0b003776
 F test/lookaside.test 1dd350dc6dff015c47c07fcc5a727a72fc5bae02
 F test/main.test 347ab987f16167858781383427476b33dc69fdb7
 F test/make-where7.tcl 05c16b5d4f5d6512881dfec560cb793915932ef9
-F test/malloc.test 3db0f384c4c5a3c62ecc35a482f8fb915e67025b
+F test/malloc.test 2d33aed76c2aab4689aef0a8cbf0c8d48bacbf37
 F test/malloc3.test 4bc57f850b212f706f3e1b37c4eced1d5a727cd1
 F test/malloc4.test 957337613002b7058a85116493a262f679f3a261
 F test/malloc5.test 4d16d1bb26d2deddd7c4f480deec341f9b2d0e22
@@ -736,7 +736,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
-P 4b46805cbc9fe71f1febe9ea5f0f5634b65128e3
-R 9ec6304164ed6368f2b420838c219481
-U drh
-Z 85bde85d2f308c9e2ad6cd0b0c32a22d
+P 16680f05bd169dfb1b4bf0eb082e69701f9b07ab
+R 6e54a2a88699861ffa872d10b9c1ee9c
+U danielk1977
+Z 3e419879a697596c75cae7156314a88e
index 170a4aa8c83dd2c7fd1566cd686ce7b0dd6afddb..271db0feef936ee45ce50f105222644b812bb513 100644 (file)
@@ -1 +1 @@
-16680f05bd169dfb1b4bf0eb082e69701f9b07ab
\ No newline at end of file
+971a9650f66f079630489c34e40003eee97d1683
\ No newline at end of file
index dcf4d2265ba0e47ebd4525715998a6a287255d5c..ebf42ef04857ab085908869b158efa5aa9282543 100644 (file)
@@ -18,7 +18,7 @@
 ** file simultaneously, or one process from reading the database while
 ** another is writing.
 **
-** @(#) $Id: pager.c,v 1.600 2009/06/20 18:52:50 danielk1977 Exp $
+** @(#) $Id: pager.c,v 1.601 2009/06/22 05:43:24 danielk1977 Exp $
 */
 #ifndef SQLITE_OMIT_DISKIO
 #include "sqliteInt.h"
@@ -3869,6 +3869,7 @@ int sqlite3PagerAcquire(
 
   rc = sqlite3PcacheFetch(pPager->pPCache, pgno, 1, &pPg);
   if( rc!=SQLITE_OK ){
+    pagerUnlockIfUnused(pPager);
     return rc;
   }
   assert( pPg->pgno==pgno );
index 29334976400aea1199f1a5d410951c85b1c6a4e5..2ea93204fea77791ea20088b350dbf3640e50cf1 100644 (file)
@@ -16,7 +16,7 @@
 # to see what happens in the library if a malloc were to really fail
 # due to an out-of-memory situation.
 #
-# $Id: malloc.test,v 1.79 2009/06/06 16:08:23 danielk1977 Exp $
+# $Id: malloc.test,v 1.80 2009/06/22 05:43:24 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -841,6 +841,29 @@ do_malloc_test 36 -sqlprep {
   SELECT test_agg_errmsg16(), group_concat(a) FROM t1
 }
 
+# At one point, if an OOM occured immediately after obtaining a shared lock
+# on the database file, the file remained locked. This test case ensures
+# that bug has been fixed.
+do_malloc_test 36 -tclprep {
+  sqlite3 db2 test.db
+  execsql {
+    CREATE TABLE t1(a, b);
+    INSERT INTO t1 VALUES(1, 2);
+  } db2
+} -sqlbody {
+  SELECT * FROM t1;
+} -cleanup {
+  # Try to write to the database using connection [db2]. If connection [db]
+  # has correctly released the shared lock, this write attempt should 
+  # succeed. If [db] has not released the lock, this should hit an 
+  # SQLITE_BUSY error.
+  do_test malloc-36.$zRepeat.${::n}.unlocked {
+    execsql {INSERT INTO t1 VALUES(3, 4)} db2
+  } {}
+  db2 close
+}
+catch { db2 close }
+
 # Ensure that no file descriptors were leaked.
 do_test malloc-99.X {
   catch {db close}