/ Check-in [cf86affc]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Make wal_checkpoint a no-op if a prior checkpoint has already copied all WAL content into the database. This prevents a concurrent write to the database from resetting the wal-index out from under the WalIterator of the checkpoint as it is initializing.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: cf86affcb7d3089496e9849cbf43a211097e4f64
User & Date: drh 2010-12-16 02:06:30
References
2011-02-20
03:20
Backport the changes of checkin [cf86affcb7d308949] ("Make wal_checkpoint a no-op if a prior checkpoint has already copied all WAL content into the database.") to the 3.7.4 release. check-in: e6e540ab user: drh tags: branch-3.7.4
Context
2010-12-16
19:52
Fix an assertion fault that can only occur if SQLITE_ENABLE_STAT2 is defined and the constant folding optimization is disabled using sqlite3_test_control(). Problem introduced by [ad8bc68197f2b4] but we missed it prior to the 3.7.4 release due to taking shortcuts and skipping tests in the release checklist. check-in: 70a3d817 user: drh tags: trunk
02:06
Make wal_checkpoint a no-op if a prior checkpoint has already copied all WAL content into the database. This prevents a concurrent write to the database from resetting the wal-index out from under the WalIterator of the checkpoint as it is initializing. check-in: cf86affc user: drh tags: trunk
2010-12-15
21:02
Enhanced comments in wal.c and declare some procedure parameters "const". No changes to the generated code. check-in: d0e4375b user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/wal.c.

  1604   1604     u32 mxPage;                     /* Max database page to write */
  1605   1605     int i;                          /* Loop counter */
  1606   1606     volatile WalCkptInfo *pInfo;    /* The checkpoint status information */
  1607   1607   
  1608   1608     szPage = (pWal->hdr.szPage&0xfe00) + ((pWal->hdr.szPage&0x0001)<<16);
  1609   1609     testcase( szPage<=32768 );
  1610   1610     testcase( szPage>=65536 );
  1611         -  if( pWal->hdr.mxFrame==0 ) return SQLITE_OK;
         1611  +  pInfo = walCkptInfo(pWal);
         1612  +  if( pInfo->nBackfill>=pWal->hdr.mxFrame ) return SQLITE_OK;
  1612   1613   
  1613   1614     /* Allocate the iterator */
  1614   1615     rc = walIteratorInit(pWal, &pIter);
  1615   1616     if( rc!=SQLITE_OK ){
  1616   1617       return rc;
  1617   1618     }
  1618   1619     assert( pIter );
................................................................................
  1626   1627     /* Compute in mxSafeFrame the index of the last frame of the WAL that is
  1627   1628     ** safe to write into the database.  Frames beyond mxSafeFrame might
  1628   1629     ** overwrite database pages that are in use by active readers and thus
  1629   1630     ** cannot be backfilled from the WAL.
  1630   1631     */
  1631   1632     mxSafeFrame = pWal->hdr.mxFrame;
  1632   1633     mxPage = pWal->hdr.nPage;
  1633         -  pInfo = walCkptInfo(pWal);
  1634   1634     for(i=1; i<WAL_NREADER; i++){
  1635   1635       u32 y = pInfo->aReadMark[i];
  1636   1636       if( mxSafeFrame>=y ){
  1637   1637         assert( y<=pWal->hdr.mxFrame );
  1638   1638         rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1);
  1639   1639         if( rc==SQLITE_OK ){
  1640   1640           pInfo->aReadMark[i] = READMARK_NOT_USED;