/ Check-in [033ee92b]
Login

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

Overview
Comment:Extra comments on the sqlite3OsShmMap() call in walBeginUnlocked(). No changes to code.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | readonly-wal-recovery
Files: files | file ages | folders
SHA3-256: 033ee92bf4d5dc57f5cb8fd02d1154ae06f2d3261d214e7191a82c70c8ffebf7
User & Date: drh 2017-11-08 19:26:27
Context
2017-11-09
16:30
Initial work on porting the changes on this branch to Win32. check-in: 3738bfd0 user: mistachkin tags: readonly-wal-recovery
2017-11-08
19:26
Extra comments on the sqlite3OsShmMap() call in walBeginUnlocked(). No changes to code. check-in: 033ee92b user: drh tags: readonly-wal-recovery
17:51
Turns out that SQLITE_READONLY_CANTLOCK is an historical name that must be preserved. So make a new SQLITE_READLOCK_CANTINIT name instead. check-in: 04974a8b user: drh tags: readonly-wal-recovery
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/wal.c.

  2206   2206       goto begin_unlocked_out;
  2207   2207     }
  2208   2208     pWal->readLock = 0;
  2209   2209   
  2210   2210     /* Try to map the *-shm file again. If it succeeds this time, then 
  2211   2211     ** a non-readonly_shm connection has already connected to the database.
  2212   2212     ** In this case, start over with opening the transaction.
         2213  +  **
         2214  +  ** The *-shm file was opened read-only, so sqlite3OsShmMap() can never
         2215  +  ** return SQLITE_OK here, as that would imply that it had established
         2216  +  ** a read/write mapping.  A return of SQLITE_READONLY means success - that
         2217  +  ** a mapping has been established to a shared-memory segment that is actively
         2218  +  ** maintained by a writer.  SQLITE_READONLY_CANTINIT means that all
         2219  +  ** all connections to the -shm file are read-only and hence the content
         2220  +  ** of the -shm file might be out-of-date.
  2213   2221     ** 
  2214   2222     ** The WAL_READ_LOCK(0) lock held by this client prevents a checkpoint
  2215   2223     ** from taking place. But it does not prevent the wal from being wrapped
  2216   2224     ** if a checkpoint has already taken place. This means that if another
  2217   2225     ** client is connected at this point, it may have already checkpointed 
  2218   2226     ** the entire wal. In that case it would not be safe to continue with
  2219   2227     ** the unlocked transaction, as the other client may overwrite wal 
  2220   2228     ** frames that this client is still using.  */
  2221   2229     rc = sqlite3OsShmMap(pWal->pDbFd, 0, WALINDEX_PGSZ, 0, &pDummy);
         2230  +  assert( rc!=SQLITE_OK ); /* SQLITE_OK not possible for read-only connection */
  2222   2231     if( rc!=SQLITE_READONLY_CANTINIT ){
  2223         -    assert( rc!=SQLITE_OK );
  2224   2232       rc = (rc==SQLITE_READONLY ? WAL_RETRY : rc);
  2225   2233       goto begin_unlocked_out;
  2226   2234     }
  2227   2235   
  2228   2236     memcpy(&pWal->hdr, (void*)walIndexHdr(pWal), sizeof(WalIndexHdr));
  2229   2237     rc = sqlite3OsFileSize(pWal->pWalFd, &szWal);
  2230   2238     if( rc!=SQLITE_OK ){