1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Call fsync() right after ftruncate() when in journal_mode=TRUNCATE and

when synchronous=FULL in order to ensure that transactions are durable
across a power loss that happens moments after the commit.  Proposed
fix for [https://bugzilla.mozilla.org/show_bug.cgi?id=1072773].

FossilOrigin-Name: 3e922208b68563489c7766abb9afb4885113e7b8
This commit is contained in:
drh
2014-10-21 21:56:06 +00:00
parent f7f2e84a9c
commit 442c5cd3cf
3 changed files with 15 additions and 7 deletions

View File

@@ -1941,6 +1941,14 @@ static int pager_end_transaction(Pager *pPager, int hasMaster, int bCommit){
rc = SQLITE_OK;
}else{
rc = sqlite3OsTruncate(pPager->jfd, 0);
if( rc==SQLITE_OK && pPager->fullSync ){
/* Make sure the new file size is written into the inode right away.
** Otherwise the journal might resurrect following a power loss and
** cause the last transaction to roll back. See
** https://bugzilla.mozilla.org/show_bug.cgi?id=1072773
*/
rc = sqlite3OsSync(pPager->jfd, pPager->syncFlags);
}
}
pPager->journalOff = 0;
}else if( pPager->journalMode==PAGER_JOURNALMODE_PERSIST