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

Block on the WRITER lock when attempting to run recovery.

FossilOrigin-Name: 105d6c9bbcadc64faa2b24e315cb13227b17cfc6bf1b3512713f80ce56976a3d
This commit is contained in:
dan
2020-05-06 19:14:41 +00:00
parent d0e6d13301
commit 861fb1e9dc
8 changed files with 130 additions and 97 deletions

View File

@@ -3442,9 +3442,10 @@ int sqlite3BtreeBeginTrans(Btree *p, int wrflag, int *pSchemaVersion){
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
/* If transitioning from no transaction directly to a write transaction,
** block for the WRITER lock first if possible. */
sqlite3PagerWalDb(pPager, p->db);
if( pBt->pPage1==0 && wrflag ){
assert( pBt->inTransaction==TRANS_NONE );
rc = sqlite3PagerWalWriteLock(p->db, pPager, 1);
rc = sqlite3PagerWalWriteLock(pPager, 1);
if( rc!=SQLITE_OK ) break;
}
#endif
@@ -3475,9 +3476,10 @@ int sqlite3BtreeBeginTrans(Btree *p, int wrflag, int *pSchemaVersion){
}
if( rc!=SQLITE_OK ){
sqlite3PagerWalWriteLock(p->db, pPager, 0);
sqlite3PagerWalWriteLock(pPager, 0);
unlockBtreeIfUnused(pBt);
}
sqlite3PagerWalDb(pPager, 0);
}while( (rc&0xFF)==SQLITE_BUSY && pBt->inTransaction==TRANS_NONE &&
btreeInvokeBusyHandler(pBt) );