If after obtaining an exclusive lock to rollback a hot-journal file it is found that the journal file has been deleted, do not return an SQLITE_BUSY error. Just downgrade the lock and continue with the current operation. This eliminates a spurious SQLITE_BUSY error caused by a race condition. (CVS 6792)

FossilOrigin-Name: 9a0666003764774b0bf861687002f8db9fd314b1
This commit is contained in:
danielk1977 2009-06-20 11:54:39 +00:00
parent 9afedcc0b8
commit 641a0bd205
3 changed files with 27 additions and 26 deletions

View File

@ -1,5 +1,5 @@
C Improved\sdocumentation\son\sthe\sVFS\smethods.\s\sTicket\s#3925.\s(CVS\s6791)
D 2009-06-19T22:50:31
C If\safter\sobtaining\san\sexclusive\slock\sto\srollback\sa\shot-journal\sfile\sit\sis\sfound\sthat\sthe\sjournal\sfile\shas\sbeen\sdeleted,\sdo\snot\sreturn\san\sSQLITE_BUSY\serror.\sJust\sdowngrade\sthe\slock\sand\scontinue\swith\sthe\scurrent\soperation.\sThis\seliminates\sa\sspurious\sSQLITE_BUSY\serror\scaused\sby\sa\srace\scondition.\s(CVS\s6792)
D 2009-06-20T11:54:39
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 507655773b384471fc05addcdcff4df100afb43b
F src/pager.c f6d5aa971a4d414ef4a1fb3a82671b62a7289f2c
F src/pager.h 5aec418bf99f568b92ae82816a1463400513726d
F src/parse.y b6e99f4208a34eb83c62f20dd67f8d9058e86768
F src/pcache.c 395f752a13574120bd7513a400ba02a265aaa76d
@ -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 605520ec04061e389226fbec59f7aedf674b3c4e
R 77263e60d51c5790c85677dbbe783a27
U drh
Z 9de7a6e0110fa6991e4ef3a2f917372e
P f66fc7713ec5ff8cf92e875e904f079d724b0477
R 40c7ff61e852d4cc9604ee6e6c9bbbd4
U danielk1977
Z 867454200d76158649fd516091f8285f

View File

@ -1 +1 @@
f66fc7713ec5ff8cf92e875e904f079d724b0477
9a0666003764774b0bf861687002f8db9fd314b1

View File

@ -18,7 +18,7 @@
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.598 2009/06/19 17:50:02 danielk1977 Exp $
** @(#) $Id: pager.c,v 1.599 2009/06/20 11:54:39 danielk1977 Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
@ -3571,17 +3571,13 @@ static int pagerSharedLock(Pager *pPager){
int rc = SQLITE_OK; /* Return code */
int isErrorReset = 0; /* True if recovering from error state */
/* If this database is opened for exclusive access, has no outstanding
** page references and is in an error-state, this is a chance to clear
** the error. Discard the contents of the pager-cache and treat any
** open journal file as a hot-journal.
/* If this database has no outstanding page references and is in an
** error-state, this is a chance to clear the error. Discard the
** contents of the pager-cache and rollback any hot journal in the
** file-system.
*/
if( !MEMDB
&& sqlite3PcacheRefCount(pPager->pPCache)==0 && pPager->errCode
){
if( isOpen(pPager->jfd) ){
isErrorReset = 1;
}
if( !MEMDB && sqlite3PcacheRefCount(pPager->pPCache)==0 && pPager->errCode ){
isErrorReset = 1;
pPager->errCode = SQLITE_OK;
pager_reset(pPager);
}
@ -3662,9 +3658,12 @@ static int pagerSharedLock(Pager *pPager){
sqlite3OsClose(pPager->jfd);
}
}else{
/* If the journal does not exist, that means some other process
** has already rolled it back */
rc = SQLITE_BUSY;
/* If the journal does not exist, it usually means that some
** other connection managed to get in and roll it back before
** this connection obtained the exclusive lock above. Or, it
** may mean that the pager was in the error-state when this
** function was called and the journal file does not exist. */
rc = pager_end_transaction(pPager, 0);
}
}
}
@ -3683,10 +3682,12 @@ static int pagerSharedLock(Pager *pPager){
** playing back the hot-journal so that we don't end up with
** an inconsistent cache.
*/
rc = pager_playback(pPager, 1);
if( rc!=SQLITE_OK ){
rc = pager_error(pPager, rc);
goto failed;
if( isOpen(pPager->jfd) ){
rc = pager_playback(pPager, 1);
if( rc!=SQLITE_OK ){
rc = pager_error(pPager, rc);
goto failed;
}
}
assert( (pPager->state==PAGER_SHARED)
|| (pPager->exclusiveMode && pPager->state>PAGER_SHARED)