diff options
author | dan <dan@noemail.net> | 2010-05-31 16:17:54 +0000 |
---|---|---|
committer | dan <dan@noemail.net> | 2010-05-31 16:17:54 +0000 |
commit | 3dee6da9949ad367cdd827f0fe255e53f4bb9ccc (patch) | |
tree | b04b45bed93e8c1e0a1152cda4565e1d0b2c09e6 /src | |
parent | 20e1f08e0bcfc35e30817dfefc5507305b5bfd8f (diff) | |
download | sqlite-3dee6da9949ad367cdd827f0fe255e53f4bb9ccc.tar.gz sqlite-3dee6da9949ad367cdd827f0fe255e53f4bb9ccc.zip |
Zero the checkpoint header as the last step of successful WAL recovery. Avoid an unnecessary lock/unlock in WalBeginReadTransaction.
FossilOrigin-Name: db3509c55dfe288650b803622e3a0828c6e59aea
Diffstat (limited to 'src')
-rw-r--r-- | src/wal.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -264,7 +264,7 @@ struct WalIndexHdr { u32 iChange; /* Counter incremented each transaction */ u16 bigEndCksum; /* True if checksums in WAL are big-endian */ u16 szPage; /* Database page size in bytes */ - u32 mxFrame; /* Index of last valid frame in the WAL */ + u32 mxFrame; /* Index of last valid frame in the WAL */ u32 nPage; /* Size of database in pages */ u32 aFrameCksum[2]; /* Checksum of last frame in log */ u32 aSalt[2]; /* Two salt values copied from WAL header */ @@ -1050,6 +1050,12 @@ finished: pWal->hdr.aFrameCksum[0] = aFrameCksum[0]; pWal->hdr.aFrameCksum[1] = aFrameCksum[1]; walIndexWriteHdr(pWal); + + /* Zero the checkpoint-header. This is safe because this thread is + ** currently holding locks that exclude all other readers, writers and + ** checkpointers. + */ + memset((void *)walCkptInfo(pWal), 0, sizeof(WalCkptInfo)); } recovery_error: @@ -1613,6 +1619,7 @@ static int walIndexReadHdr(Wal *pWal, int *pChanged){ ** needs to be reconstructed. So run recovery to do exactly that. */ rc = walIndexRecover(pWal); + *pChanged = 1; } walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1); pWal->writeLock = 0; @@ -1752,8 +1759,7 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal){ for(i=1; i<WAL_NREADER; i++){ rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1); if( rc==SQLITE_OK ){ - pInfo->aReadMark[i] = pWal->hdr.mxFrame+1; - mxReadMark = pWal->hdr.mxFrame; + mxReadMark = pInfo->aReadMark[i] = pWal->hdr.mxFrame+1; mxI = i; walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1); break; |