/ Check-in [4a0b29dc]
Login

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

Overview
Comment:Fix a pager bug introduced by the wal code.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wal
Files: files | file ages | folders
SHA1: 4a0b29dc5e573a5d696ede17db5d7acf8d23aa98
User & Date: dan 2010-04-13 11:18:40
Context
2010-04-13
11:35
Fix test script issues preventing walthread.test from running. check-in: d90b1dde user: dan tags: wal
11:18
Fix a pager bug introduced by the wal code. check-in: 4a0b29dc user: dan tags: wal
06:20
Sync wal branch with [012cf101bf]. check-in: 9d690f24 user: dan tags: wal
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pager.c.

  3778   3778       if( isOpen(pPager->jfd) || pPager->zJournal ){
  3779   3779         isErrorReset = 1;
  3780   3780       }
  3781   3781       pPager->errCode = SQLITE_OK;
  3782   3782       pager_reset(pPager);
  3783   3783     }
  3784   3784   
  3785         -  if( pPager->noReadlock ){
  3786         -    assert( pPager->readOnly );
  3787         -    pPager->state = PAGER_SHARED;
  3788         -  }else{
         3785  +  if( pagerUseLog(pPager) ){
         3786  +    int changed = 0;
         3787  +
         3788  +    /* TODO: Change the following block to grab a WAL read-lock. Or, 
         3789  +    ** combine obtaining the read-lock with LogOpenSnapshot()?  */
  3789   3790       rc = pager_wait_on_lock(pPager, SHARED_LOCK);
  3790   3791       if( rc!=SQLITE_OK ){
  3791   3792         assert( pPager->state==PAGER_UNLOCK );
  3792   3793         return pager_error(pPager, rc);
  3793   3794       }
  3794         -  }
  3795         -  assert( pPager->state>=SHARED_LOCK );
  3796   3795   
  3797         -  if( pagerUseLog(pPager) ){
  3798         -    int changed = 0;
  3799   3796       rc = sqlite3LogOpenSnapshot(pPager->pLog, &changed);
  3800   3797       if( rc==SQLITE_OK ){
  3801   3798         if( changed ){
  3802   3799           pager_reset(pPager);
  3803   3800           assert( pPager->errCode || pPager->dbSizeValid==0 );
  3804   3801         }
  3805   3802         pPager->state = PAGER_SHARED;
................................................................................
  3806   3803         rc = sqlite3PagerPagecount(pPager, &changed);
  3807   3804       }
  3808   3805     }else if( pPager->state==PAGER_UNLOCK || isErrorReset ){
  3809   3806       sqlite3_vfs * const pVfs = pPager->pVfs;
  3810   3807       int isHotJournal = 0;
  3811   3808       assert( !MEMDB );
  3812   3809       assert( sqlite3PcacheRefCount(pPager->pPCache)==0 );
         3810  +    if( pPager->noReadlock ){
         3811  +      assert( pPager->readOnly );
         3812  +      pPager->state = PAGER_SHARED;
         3813  +    }else{
         3814  +      rc = pager_wait_on_lock(pPager, SHARED_LOCK);
         3815  +      if( rc!=SQLITE_OK ){
         3816  +        assert( pPager->state==PAGER_UNLOCK );
         3817  +        return pager_error(pPager, rc);
         3818  +      }
         3819  +    }
         3820  +    assert( pPager->state>=SHARED_LOCK );
  3813   3821   
  3814   3822       /* If a journal file exists, and there is no RESERVED lock on the
  3815   3823       ** database file, then it either needs to be played back or deleted.
  3816   3824       */
  3817   3825       if( !isErrorReset ){
  3818   3826         assert( pPager->state <= PAGER_SHARED );
  3819   3827         rc = hasHotJournal(pPager, &isHotJournal);

Changes to test/quick.test.

    97     97     incrvacuum_ioerr.test
    98     98     autovacuum_crash.test
    99     99     btree8.test
   100    100     shared_err.test
   101    101     vtab_err.test
   102    102     veryquick.test
   103    103     mallocAll.test
          104  +
          105  +  walslow.test
          106  +  walcrash.test
   104    107   }
   105    108   
   106    109   if {[sqlite3 -has-codec]} {
   107    110     # lappend EXCLUDE \
   108    111     #  conflict.test
   109    112   }
   110    113