mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
When saving the state of an RBU update in the incremental-checkpoint phase,
sync the database file. Otherwise, if a power failure occurs and the RBU update resumed following system recovery, the database may become corrupt. FossilOrigin-Name: edee6a80e1cc7e6a2b8c3c7f76dd794fc8ab9a72
This commit is contained in:
@ -3718,6 +3718,12 @@ int sqlite3rbu_close(sqlite3rbu *p, char **pzErrmsg){
|
||||
p->rc = sqlite3_exec(p->dbMain, "COMMIT", 0, 0, &p->zErrmsg);
|
||||
}
|
||||
|
||||
/* Sync the db file if currently doing an incremental checkpoint */
|
||||
if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_CKPT ){
|
||||
sqlite3_file *pDb = p->pTargetFd->pReal;
|
||||
p->rc = pDb->pMethods->xSync(pDb, SQLITE_SYNC_NORMAL);
|
||||
}
|
||||
|
||||
rbuSaveState(p, p->eStage);
|
||||
|
||||
if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_OAL ){
|
||||
@ -3842,6 +3848,12 @@ int sqlite3rbu_savestate(sqlite3rbu *p){
|
||||
if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbMain, "COMMIT", 0, 0, 0);
|
||||
}
|
||||
|
||||
/* Sync the db file */
|
||||
if( rc==SQLITE_OK && p->eStage==RBU_STAGE_CKPT ){
|
||||
sqlite3_file *pDb = p->pTargetFd->pReal;
|
||||
rc = pDb->pMethods->xSync(pDb, SQLITE_SYNC_NORMAL);
|
||||
}
|
||||
|
||||
p->rc = rc;
|
||||
rbuSaveState(p, p->eStage);
|
||||
rc = p->rc;
|
||||
|
Reference in New Issue
Block a user