/ Check-in [9c6b38b9]
Login

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

Overview
Comment:Remove some branches in walTryBeginRead() that were added by check-in [ce5d13c2de] but became unreachable with the addition of logic in check-in [18b26843] that enabled read-only clients to parse the WAL file into a heap-memory WAL-index, thus guaranteeing that the WAL-index header is always available.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | readonly-wal-recovery
Files: files | file ages | folders
SHA3-256: 9c6b38b9a96c11bdf9db4ea025720a4f49dcb723fa2e2776edc8453bce85c7e3
User & Date: drh 2017-11-13 05:51:37
Context
2017-11-14
03:42
Improvement to a comment. No changes to code. Closed-Leaf check-in: 486949fc user: drh tags: readonly-wal-recovery
2017-11-13
05:51
Remove some branches in walTryBeginRead() that were added by check-in [ce5d13c2de] but became unreachable with the addition of logic in check-in [18b26843] that enabled read-only clients to parse the WAL file into a heap-memory WAL-index, thus guaranteeing that the WAL-index header is always available. check-in: 9c6b38b9 user: drh tags: readonly-wal-recovery
2017-11-11
20:11
In wal.c: improved comments, new assert() and testcase() macros, and replace some magic numbers with appropriate symbolic constants. check-in: 13ec8a77 user: drh tags: readonly-wal-recovery
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/wal.c.

  2414   2414     int mxI;                        /* Index of largest aReadMark[] value */
  2415   2415     int i;                          /* Loop counter */
  2416   2416     int rc = SQLITE_OK;             /* Return code  */
  2417   2417     u32 mxFrame;                    /* Wal frame to lock to */
  2418   2418   
  2419   2419     assert( pWal->readLock<0 );     /* Not currently locked */
  2420   2420   
         2421  +  /* useWal may only be set for read/write connections */
         2422  +  assert( (pWal->readOnly & WAL_SHM_RDONLY)==0 || useWal==0 );
         2423  +
  2421   2424     /* Take steps to avoid spinning forever if there is a protocol error.
  2422   2425     **
  2423   2426     ** Circumstances that cause a RETRY should only last for the briefest
  2424   2427     ** instances of time.  No I/O or other system calls are done while the
  2425   2428     ** locks are held, so the locks should not be held for very long. But 
  2426   2429     ** if we are unlucky, another process that is holding a lock might get
  2427   2430     ** paged out or take a page-fault that is time-consuming to resolve, 
................................................................................
  2480   2483       }
  2481   2484       else if( pWal->bShmUnreliable ){
  2482   2485         return walBeginShmUnreliable(pWal, pChanged);
  2483   2486       }
  2484   2487     }
  2485   2488   
  2486   2489     assert( pWal->nWiData>0 );
  2487         -  assert( pWal->apWiData[0] || (pWal->readOnly & WAL_SHM_RDONLY) );
  2488         -  pInfo = pWal->apWiData[0] ? walCkptInfo(pWal) : 0;
  2489         -  if( !useWal && (pInfo==0 || pInfo->nBackfill==pWal->hdr.mxFrame)
         2490  +  assert( pWal->apWiData[0]!=0 );
         2491  +  pInfo = walCkptInfo(pWal);
         2492  +  if( !useWal && pInfo->nBackfill==pWal->hdr.mxFrame
  2490   2493   #ifdef SQLITE_ENABLE_SNAPSHOT
  2491   2494      && (pWal->pSnapshot==0 || pWal->hdr.mxFrame==0
  2492   2495        || 0==memcmp(&pWal->hdr, pWal->pSnapshot, sizeof(WalIndexHdr)))
  2493   2496   #endif
  2494   2497     ){
  2495   2498       /* The WAL has been completely backfilled (or it is empty).
  2496   2499       ** and can be safely ignored.
  2497   2500       */
  2498   2501       rc = walLockShared(pWal, WAL_READ_LOCK(0));
  2499   2502       walShmBarrier(pWal);
  2500   2503       if( rc==SQLITE_OK ){
  2501         -      if( pInfo
  2502         -       && memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr)) 
  2503         -      ){
         2504  +      if( memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr)) ){
  2504   2505           /* It is not safe to allow the reader to continue here if frames
  2505   2506           ** may have been appended to the log before READ_LOCK(0) was obtained.
  2506   2507           ** When holding READ_LOCK(0), the reader ignores the entire log file,
  2507   2508           ** which implies that the database file contains a trustworthy
  2508   2509           ** snapshot. Since holding READ_LOCK(0) prevents a checkpoint from
  2509   2510           ** happening, this is usually correct.
  2510   2511           **