mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Add evidence marks and assert()s used as evidence for checkpoint requirements.
FossilOrigin-Name: b2da8afc7657266fbe8e683c6e50fe18216cbcf3
This commit is contained in:
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Fix\sover-length\scomment\slines\sin\ssqlite.h.in.\s\sNo\schanges\sto\scode.
|
C Add\sevidence\smarks\sand\sassert()s\sused\sas\sevidence\sfor\scheckpoint\srequirements.
|
||||||
D 2014-12-03T19:08:00.822
|
D 2014-12-03T19:25:41.425
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in a226317fdf3f4c895fb3cfedc355b4d0868ce1fb
|
F Makefile.in a226317fdf3f4c895fb3cfedc355b4d0868ce1fb
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@@ -216,7 +216,7 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa
|
|||||||
F src/os_unix.c fb587121840f690101336879adfa6d0b2cd0e8c7
|
F src/os_unix.c fb587121840f690101336879adfa6d0b2cd0e8c7
|
||||||
F src/os_win.c a9e500dd963fb1f67d7860e58b5772abe6123862
|
F src/os_win.c a9e500dd963fb1f67d7860e58b5772abe6123862
|
||||||
F src/os_win.h 09e751b20bbc107ffbd46e13555dc73576d88e21
|
F src/os_win.h 09e751b20bbc107ffbd46e13555dc73576d88e21
|
||||||
F src/pager.c b8764f90c135482988268eec93d7f5cdb89d687a
|
F src/pager.c 7a5c5bc0e29b9b16834f5558a9d5d22bbae59a08
|
||||||
F src/pager.h d1eee3c3f741be247ce6d82752a178515fc8578b
|
F src/pager.h d1eee3c3f741be247ce6d82752a178515fc8578b
|
||||||
F src/parse.y 5dfead8aed90cb0c7c1115898ee2266804daff45
|
F src/parse.y 5dfead8aed90cb0c7c1115898ee2266804daff45
|
||||||
F src/pcache.c ace1b67632deeaa84859b4c16c27711dfb7db3d4
|
F src/pcache.c ace1b67632deeaa84859b4c16c27711dfb7db3d4
|
||||||
@@ -301,7 +301,7 @@ F src/vdbemem.c 31d8eabb0cd78bfeab4e5124c7363c3e9e54db9f
|
|||||||
F src/vdbesort.c 42c166f7ca78cb643c7f4e4bdfa83c59d363d1a6
|
F src/vdbesort.c 42c166f7ca78cb643c7f4e4bdfa83c59d363d1a6
|
||||||
F src/vdbetrace.c 7e4222955e07dd707a2f360c0eb73452be1cb010
|
F src/vdbetrace.c 7e4222955e07dd707a2f360c0eb73452be1cb010
|
||||||
F src/vtab.c c08ec66f45919eaa726bf88aa53eb08379d607f9
|
F src/vtab.c c08ec66f45919eaa726bf88aa53eb08379d607f9
|
||||||
F src/wal.c e396f31038aa01b9de95584b703692716275aedc
|
F src/wal.c fc62ec9dc7dfa08dbe08801332230cf28130a159
|
||||||
F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
|
F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
|
||||||
F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804
|
F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804
|
||||||
F src/where.c a0b16f9d78321cb340a977287d19f826555c7d3b
|
F src/where.c a0b16f9d78321cb340a977287d19f826555c7d3b
|
||||||
@@ -1223,7 +1223,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
|||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||||
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
||||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||||
P 026c44ff2c092b14faa19985dd46873aeb8727dc
|
P cbd357fd8c25c9c6043063710a3e2a89ff8b4575
|
||||||
R 4ed5b70763e0743b0e322aa2df0b85da
|
R bf75abced12e09ba377b1add0a3ea61a
|
||||||
U drh
|
U drh
|
||||||
Z 6507e8b7c8c2131b9414f714dc2b9292
|
Z 0545aa7eaccc2c8413582324bb7aef19
|
||||||
|
@@ -1 +1 @@
|
|||||||
cbd357fd8c25c9c6043063710a3e2a89ff8b4575
|
b2da8afc7657266fbe8e683c6e50fe18216cbcf3
|
@@ -7075,7 +7075,8 @@ int sqlite3PagerCheckpoint(Pager *pPager, int eMode, int *pnLog, int *pnCkpt){
|
|||||||
int rc = SQLITE_OK;
|
int rc = SQLITE_OK;
|
||||||
if( pPager->pWal ){
|
if( pPager->pWal ){
|
||||||
rc = sqlite3WalCheckpoint(pPager->pWal, eMode,
|
rc = sqlite3WalCheckpoint(pPager->pWal, eMode,
|
||||||
pPager->xBusyHandler, pPager->pBusyHandlerArg,
|
(eMode==SQLITE_CHECKPOINT_PASSIVE ? 0 : pPager->xBusyHandler),
|
||||||
|
pPager->pBusyHandlerArg,
|
||||||
pPager->ckptSyncFlags, pPager->pageSize, (u8 *)pPager->pTmpSpace,
|
pPager->ckptSyncFlags, pPager->pageSize, (u8 *)pPager->pTmpSpace,
|
||||||
pnLog, pnCkpt
|
pnLog, pnCkpt
|
||||||
);
|
);
|
||||||
|
45
src/wal.c
45
src/wal.c
@@ -1689,7 +1689,7 @@ static void walRestartHdr(Wal *pWal, u32 salt1){
|
|||||||
static int walCheckpoint(
|
static int walCheckpoint(
|
||||||
Wal *pWal, /* Wal connection */
|
Wal *pWal, /* Wal connection */
|
||||||
int eMode, /* One of PASSIVE, FULL or RESTART */
|
int eMode, /* One of PASSIVE, FULL or RESTART */
|
||||||
int (*xBusyCall)(void*), /* Function to call when busy */
|
int (*xBusy)(void*), /* Function to call when busy */
|
||||||
void *pBusyArg, /* Context argument for xBusyHandler */
|
void *pBusyArg, /* Context argument for xBusyHandler */
|
||||||
int sync_flags, /* Flags for OsSync() (or 0) */
|
int sync_flags, /* Flags for OsSync() (or 0) */
|
||||||
u8 *zBuf /* Temporary buffer to use */
|
u8 *zBuf /* Temporary buffer to use */
|
||||||
@@ -1703,7 +1703,6 @@ static int walCheckpoint(
|
|||||||
u32 mxPage; /* Max database page to write */
|
u32 mxPage; /* Max database page to write */
|
||||||
int i; /* Loop counter */
|
int i; /* Loop counter */
|
||||||
volatile WalCkptInfo *pInfo; /* The checkpoint status information */
|
volatile WalCkptInfo *pInfo; /* The checkpoint status information */
|
||||||
int (*xBusy)(void*) = 0; /* Function to call when waiting for locks */
|
|
||||||
|
|
||||||
szPage = walPagesize(pWal);
|
szPage = walPagesize(pWal);
|
||||||
testcase( szPage<=32768 );
|
testcase( szPage<=32768 );
|
||||||
@@ -1718,7 +1717,9 @@ static int walCheckpoint(
|
|||||||
}
|
}
|
||||||
assert( pIter );
|
assert( pIter );
|
||||||
|
|
||||||
if( eMode!=SQLITE_CHECKPOINT_PASSIVE ) xBusy = xBusyCall;
|
/* EVIDENCE-OF: R-62920-47450 The busy-handler callback is never invoked
|
||||||
|
** in the SQLITE_CHECKPOINT_PASSIVE mode. */
|
||||||
|
assert( eMode!=SQLITE_CHECKPOINT_PASSIVE || xBusy==0 );
|
||||||
|
|
||||||
/* Compute in mxSafeFrame the index of the last frame of the WAL that is
|
/* Compute in mxSafeFrame the index of the last frame of the WAL that is
|
||||||
** safe to write into the database. Frames beyond mxSafeFrame might
|
** safe to write into the database. Frames beyond mxSafeFrame might
|
||||||
@@ -2943,7 +2944,7 @@ int sqlite3WalFrames(
|
|||||||
*/
|
*/
|
||||||
int sqlite3WalCheckpoint(
|
int sqlite3WalCheckpoint(
|
||||||
Wal *pWal, /* Wal connection */
|
Wal *pWal, /* Wal connection */
|
||||||
int eMode, /* PASSIVE, FULL or RESTART */
|
int eMode, /* PASSIVE, FULL, RESTART, or TRUNCATE */
|
||||||
int (*xBusy)(void*), /* Function to call when busy */
|
int (*xBusy)(void*), /* Function to call when busy */
|
||||||
void *pBusyArg, /* Context argument for xBusyHandler */
|
void *pBusyArg, /* Context argument for xBusyHandler */
|
||||||
int sync_flags, /* Flags to sync db file with (or 0) */
|
int sync_flags, /* Flags to sync db file with (or 0) */
|
||||||
@@ -2955,29 +2956,42 @@ int sqlite3WalCheckpoint(
|
|||||||
int rc; /* Return code */
|
int rc; /* Return code */
|
||||||
int isChanged = 0; /* True if a new wal-index header is loaded */
|
int isChanged = 0; /* True if a new wal-index header is loaded */
|
||||||
int eMode2 = eMode; /* Mode to pass to walCheckpoint() */
|
int eMode2 = eMode; /* Mode to pass to walCheckpoint() */
|
||||||
|
int (*xBusy2)(void*) = xBusy; /* Busy handler for eMode2 */
|
||||||
|
|
||||||
assert( pWal->ckptLock==0 );
|
assert( pWal->ckptLock==0 );
|
||||||
assert( pWal->writeLock==0 );
|
assert( pWal->writeLock==0 );
|
||||||
|
|
||||||
|
/* EVIDENCE-OF: R-62920-47450 The busy-handler callback is never invoked
|
||||||
|
** in the SQLITE_CHECKPOINT_PASSIVE mode. */
|
||||||
|
assert( eMode!=SQLITE_CHECKPOINT_PASSIVE || xBusy==0 );
|
||||||
|
|
||||||
if( pWal->readOnly ) return SQLITE_READONLY;
|
if( pWal->readOnly ) return SQLITE_READONLY;
|
||||||
WALTRACE(("WAL%p: checkpoint begins\n", pWal));
|
WALTRACE(("WAL%p: checkpoint begins\n", pWal));
|
||||||
|
|
||||||
|
/* IMPLEMENTATION-OF: R-62028-47212 All calls obtain an exclusive
|
||||||
|
** "checkpoint" lock on the database file. */
|
||||||
rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1);
|
rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1);
|
||||||
if( rc ){
|
if( rc ){
|
||||||
/* Usually this is SQLITE_BUSY meaning that another thread or process
|
/* EVIDENCE-OF: R-10421-19736 If any other process is running a
|
||||||
** is already running a checkpoint, or maybe a recovery. But it might
|
** checkpoint operation at the same time, the lock cannot be obtained and
|
||||||
** also be SQLITE_IOERR. */
|
** SQLITE_BUSY is returned.
|
||||||
|
** EVIDENCE-OF: R-53820-33897 Even if there is a busy-handler configured,
|
||||||
|
** it will not be invoked in this case.
|
||||||
|
*/
|
||||||
|
testcase( rc==SQLITE_BUSY );
|
||||||
|
testcase( xBusy!=0 );
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
pWal->ckptLock = 1;
|
pWal->ckptLock = 1;
|
||||||
|
|
||||||
/* If this is a blocking-checkpoint, then obtain the write-lock as well
|
/* IMPLEMENTATION-OF: R-59782-36818 The SQLITE_CHECKPOINT_FULL, RESTART and
|
||||||
** to prevent any writers from running while the checkpoint is underway.
|
** TRUNCATE modes also obtain the exclusive "writer" lock on the database
|
||||||
** This has to be done before the call to walIndexReadHdr() below.
|
** file.
|
||||||
**
|
**
|
||||||
** If the writer lock cannot be obtained, then a passive checkpoint is
|
** EVIDENCE-OF: R-60642-04082 If the writer lock cannot be obtained
|
||||||
** run instead. Since the checkpointer is not holding the writer lock,
|
** immediately, and a busy-handler is configured, it is invoked and the
|
||||||
** there is no point in blocking waiting for any readers. Assuming no
|
** writer lock retried until either the busy-handler returns 0 or the
|
||||||
** other error occurs, this function will return SQLITE_BUSY to the caller.
|
** lock is successfully obtained.
|
||||||
*/
|
*/
|
||||||
if( eMode!=SQLITE_CHECKPOINT_PASSIVE ){
|
if( eMode!=SQLITE_CHECKPOINT_PASSIVE ){
|
||||||
rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_WRITE_LOCK, 1);
|
rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_WRITE_LOCK, 1);
|
||||||
@@ -2985,6 +2999,7 @@ int sqlite3WalCheckpoint(
|
|||||||
pWal->writeLock = 1;
|
pWal->writeLock = 1;
|
||||||
}else if( rc==SQLITE_BUSY ){
|
}else if( rc==SQLITE_BUSY ){
|
||||||
eMode2 = SQLITE_CHECKPOINT_PASSIVE;
|
eMode2 = SQLITE_CHECKPOINT_PASSIVE;
|
||||||
|
xBusy2 = 0;
|
||||||
rc = SQLITE_OK;
|
rc = SQLITE_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3002,7 +3017,7 @@ int sqlite3WalCheckpoint(
|
|||||||
if( pWal->hdr.mxFrame && walPagesize(pWal)!=nBuf ){
|
if( pWal->hdr.mxFrame && walPagesize(pWal)!=nBuf ){
|
||||||
rc = SQLITE_CORRUPT_BKPT;
|
rc = SQLITE_CORRUPT_BKPT;
|
||||||
}else{
|
}else{
|
||||||
rc = walCheckpoint(pWal, eMode2, xBusy, pBusyArg, sync_flags, zBuf);
|
rc = walCheckpoint(pWal, eMode2, xBusy2, pBusyArg, sync_flags, zBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If no error occurred, set the output variables. */
|
/* If no error occurred, set the output variables. */
|
||||||
|
Reference in New Issue
Block a user