1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

If an attempt to sync the database file as part of a checkpoint fails, do not update the shared "nBackfill" variable. Otherwise, another process could wrap the log and overwrite content before it is synced into the database.

FossilOrigin-Name: b813233d7604a5fd91e1af91d5d812032eec700a
This commit is contained in:
dan
2010-06-04 11:56:22 +00:00
parent 83f42d1b38
commit d764c7de25
5 changed files with 244 additions and 123 deletions

View File

@@ -1462,14 +1462,16 @@ static int walCheckpoint(
}
/* If work was actually accomplished... */
if( rc==SQLITE_OK && pInfo->nBackfill<mxSafeFrame ){
pInfo->nBackfill = mxSafeFrame;
if( mxSafeFrame==pHdr[0].mxFrame && sync_flags ){
if( rc==SQLITE_OK ){
if( mxSafeFrame==pHdr[0].mxFrame ){
rc = sqlite3OsTruncate(pWal->pDbFd, ((i64)pWal->hdr.nPage*(i64)szPage));
if( rc==SQLITE_OK && sync_flags ){
rc = sqlite3OsSync(pWal->pDbFd, sync_flags);
}
}
if( rc==SQLITE_OK ){
pInfo->nBackfill = mxSafeFrame;
}
}
/* Release the reader lock held while backfilling */