From 3cfe07037ff872dd0c5df375c8afc1f906d8776d Mon Sep 17 00:00:00 2001 From: danielk1977 Date: Sat, 17 Jan 2009 16:59:40 +0000 Subject: [PATCH] Fix a bug that was preventing SQLite from releasing locks properly under obscure circumstances. (CVS 6192) FossilOrigin-Name: 502c66df8b5fc5ec8e3d94202030571a4920fb9c --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/pager.c | 8 ++++---- test/lock.test | 29 ++++++++++++++++++++++++++++- 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 4ad3562d72..777a5bb892 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Back\sout\sthe\sMakefile.in\schanges\sfrom\scheck-in\s(6181)\sbecause\sof\sreports\n(ticket\s#3594)\sthat\sthey\sdo\snot\swork\son\sNetBSD.\s\sSeparately,\sdocumentation\nis\supdated\sto\smake\sclear\sthat\sconfigure\sand\sMakefile.in\sare\sunsupported.\s(CVS\s6191) -D 2009-01-17T15:53:32 +C Fix\sa\sbug\sthat\swas\spreventing\sSQLite\sfrom\sreleasing\slocks\sproperly\sunder\sobscure\scircumstances.\s(CVS\s6192) +D 2009-01-17T16:59:41 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 05461a9b5803d5ad10c79f989801e9fd2cc3e592 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -142,7 +142,7 @@ F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60 F src/os_os2.c bed77dc26e3a95ce4a204936b9a1ca6fe612fcc5 F src/os_unix.c c74255cc1fcddc38fc3cc1dcf70c2325d3c2948e F src/os_win.c 496e3ceb499aedc63622a89ef76f7af2dd902709 -F src/pager.c e8e2ae1ef6a20464a627d29fd4ba29461b7632a5 +F src/pager.c bf917e869ef44b8e277e87f5b5ac980a1ee727ef F src/pager.h 3345547d4b5b4db323f50d855d91a01837c7f2de F src/parse.y b214295a91e985c42adb6bfd3ad1c56c47828e8d F src/pcache.c a3c729f4bb3464fab27617ab7411916e0cded2bf @@ -421,7 +421,7 @@ F test/like2.test 3b2ee13149ba4a8a60b59756f4e5d345573852da F test/limit.test 2db7b3b34fb925b8e847d583d2eb67531d0ce67e F test/loadext.test 18db29c081380fdedcfbd8c633847712059ae104 F test/loadext2.test 0bcaeb4d81cd5b6e883fdfea3c1bdbe1f173cbca -F test/lock.test 3f03827e056946c4b81b74006e62ffa2a3219ab3 +F test/lock.test 3f9e98e96d331ee3035303b7431bcaac5fb087e3 F test/lock2.test 018b846f6f3b3b695fad07e317b7988442b556f4 F test/lock3.test 8adfbf438b96316267611214d494ebc1311b8cda F test/lock4.test 09d97d52cae18fadfe631552af9880dac6b3ae90 @@ -697,7 +697,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P 191c399fc6354b35477ec21f685377e2af26f49b -R 9c5b87982663f6bf52088be86c758e02 -U drh -Z 32664470dd1402b7c5c5504f3951bf6a +P 2d79aaab134c8a09722cb0466d45e04002bce54f +R fe1cb874d09c63891e7d7d8934e00ed2 +U danielk1977 +Z 2df5fb48b7bbf02bff054e8b941b04c7 diff --git a/manifest.uuid b/manifest.uuid index cb3dcd359e..281ccc3409 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2d79aaab134c8a09722cb0466d45e04002bce54f \ No newline at end of file +502c66df8b5fc5ec8e3d94202030571a4920fb9c \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 32a04f1d14..aafdb648ca 100644 --- a/src/pager.c +++ b/src/pager.c @@ -18,7 +18,7 @@ ** file simultaneously, or one process from reading the database while ** another is writing. ** -** @(#) $Id: pager.c,v 1.554 2009/01/16 16:40:14 danielk1977 Exp $ +** @(#) $Id: pager.c,v 1.555 2009/01/17 16:59:41 danielk1977 Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" @@ -4076,9 +4076,9 @@ int sqlite3PagerCommitPhaseTwo(Pager *pPager){ if( pPager->statedbModified==0 && - (pPager->journalMode!=PAGER_JOURNALMODE_DELETE || - pPager->exclusiveMode!=0) ){ + if( pPager->dbModified==0 && pPager->exclusiveMode + && pPager->journalMode==PAGER_JOURNALMODE_PERSIST + ){ assert( pPager->dirtyCache==0 || pPager->journalOpen==0 ); return SQLITE_OK; } diff --git a/test/lock.test b/test/lock.test index 30469d5b9d..b76dc91970 100644 --- a/test/lock.test +++ b/test/lock.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this script is database locks. # -# $Id: lock.test,v 1.35 2009/01/14 17:45:58 danielk1977 Exp $ +# $Id: lock.test,v 1.36 2009/01/17 16:59:41 danielk1977 Exp $ set testdir [file dirname $argv0] @@ -390,6 +390,33 @@ do_test lock-6.5 { sqlite3_finalize $STMT } {SQLITE_OK} +# At one point the following set of conditions would cause SQLite to +# retain a RESERVED or EXCLUSIVE lock after the transaction was committed: +# +# * The journal-mode is set to something other than 'delete', and +# * there exists one or more active read-only statements, and +# * a transaction that modified zero database pages is committed. +# +do_test lock-7.1 { + set STMT [sqlite3_prepare $DB "SELECT * FROM sqlite_master" -1 TAIL] + sqlite3_step $STMT +} {SQLITE_ROW} +do_test lock-7.2 { + execsql { PRAGMA lock_status } +} {main shared temp unlocked} +do_test lock-7.3 { + execsql { + PRAGMA journal_mode = truncate; + BEGIN; + UPDATE t4 SET a = 10 WHERE 0; + COMMIT; + } + execsql { PRAGMA lock_status } +} {main shared temp unlocked} +do_test lock-7.4 { + sqlite3_finalize $STMT +} {SQLITE_OK} + do_test lock-999.1 { rename db2 {} } {}