/ Check-in [9527089b]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Invoke sqlite3_log() in response to irregularities surrounding the Pager.pAllRead bit-vector.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | begin-concurrent
Files: files | file ages | folders
SHA3-256: 9527089b7aa3695cd577f31b263b4777e9bd62dbbc1bd3af892c570e52e8c3a1
User & Date: dan 2017-05-19 19:57:15
Wiki:begin-concurrent
References
2017-05-26
18:18
Adjust the bitvec related sqlite3_log messages added by [9527089b]. check-in: a7e0e7a4 user: dan tags: begin-concurrent
Context
2017-05-23
19:23
Add experimental new API sqlite3_wal_info(). check-in: 5b9d498f user: dan tags: begin-concurrent
2017-05-19
19:57
Invoke sqlite3_log() in response to irregularities surrounding the Pager.pAllRead bit-vector. check-in: 9527089b user: dan tags: begin-concurrent
2017-05-18
20:47
Fix a problem on this branch causing some page-level read-locks to be omitted. check-in: 0eed1521 user: dan tags: begin-concurrent
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/bitvec.c.

166
167
168
169
170
171
172
173





174
175
176
177
178
179
180
** and that the value for "i" is within range of the Bitvec object.
** Otherwise the behavior is undefined.
*/
int sqlite3BitvecSet(Bitvec *p, u32 i){
  u32 h;
  if( p==0 ) return SQLITE_OK;
  assert( i>0 );
  assert( i<=p->iSize );





  i--;
  while((p->iSize > BITVEC_NBIT) && p->iDivisor) {
    u32 bin = i/p->iDivisor;
    i = i%p->iDivisor;
    if( p->u.apSub[bin]==0 ){
      p->u.apSub[bin] = sqlite3BitvecCreate( p->iDivisor );
      if( p->u.apSub[bin]==0 ) return SQLITE_NOMEM_BKPT;







|
>
>
>
>
>







166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
** and that the value for "i" is within range of the Bitvec object.
** Otherwise the behavior is undefined.
*/
int sqlite3BitvecSet(Bitvec *p, u32 i){
  u32 h;
  if( p==0 ) return SQLITE_OK;
  assert( i>0 );
  /* assert( i<=p->iSize ); */
  if( i>p->iSize ){
    sqlite3_log(SQLITE_ERROR, 
        "Bitvec: setting bit %d of bitvec size %d\n", (int)i, (int)p->iSize
    );
  }
  i--;
  while((p->iSize > BITVEC_NBIT) && p->iDivisor) {
    u32 bin = i/p->iDivisor;
    i = i%p->iDivisor;
    if( p->u.apSub[bin]==0 ){
      p->u.apSub[bin] = sqlite3BitvecCreate( p->iDivisor );
      if( p->u.apSub[bin]==0 ) return SQLITE_NOMEM_BKPT;

Changes to src/pager.c.

5382
5383
5384
5385
5386
5387
5388







5389
5390
5391
5392
5393
5394
5395
....
5880
5881
5882
5883
5884
5885
5886










5887
5888
5889
5890
5891
5892
5893
  if( rc!=SQLITE_OK ){
    assert( !MEMDB );
    pager_unlock(pPager);
    assert( pPager->eState==PAGER_OPEN );
  }else{
    pPager->eState = PAGER_READER;
    pPager->hasHeldSharedLock = 1;







  }
  return rc;
}

/*
** If the reference count has reached zero, rollback any active
** transaction and unlock the pager.
................................................................................
      ** WAL mode sets Pager.eState to PAGER_WRITER_LOCKED or CACHEMOD
      ** when it has an open transaction, but never to DBMOD or FINISHED.
      ** This is because in those states the code to roll back savepoint 
      ** transactions may copy data from the sub-journal into the database 
      ** file as well as into the page cache. Which would be incorrect in 
      ** WAL mode.
      */










      pPager->eState = PAGER_WRITER_LOCKED;
      pPager->dbHintSize = pPager->dbSize;
      pPager->dbFileSize = pPager->dbSize;
      pPager->dbOrigSize = pPager->dbSize;
      pPager->journalOff = 0;
    }








>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>







5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
....
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
  if( rc!=SQLITE_OK ){
    assert( !MEMDB );
    pager_unlock(pPager);
    assert( pPager->eState==PAGER_OPEN );
  }else{
    pPager->eState = PAGER_READER;
    pPager->hasHeldSharedLock = 1;
#ifndef SQLITE_OMIT_CONCURRENT
    if( pPager->pAllRead ){
      sqlite3_log(SQLITE_ERROR, 
          "Bitvec: pAllRead already allocated in PagerSharedLock()"
      );
    }
#endif
  }
  return rc;
}

/*
** If the reference count has reached zero, rollback any active
** transaction and unlock the pager.
................................................................................
      ** WAL mode sets Pager.eState to PAGER_WRITER_LOCKED or CACHEMOD
      ** when it has an open transaction, but never to DBMOD or FINISHED.
      ** This is because in those states the code to roll back savepoint 
      ** transactions may copy data from the sub-journal into the database 
      ** file as well as into the page cache. Which would be incorrect in 
      ** WAL mode.
      */
#ifndef SQLITE_OMIT_CONCURRENT
      if( pPager->pAllRead 
       && pPager->dbSize!=sqlite3BitvecSize(pPager->pAllRead) 
      ){
        sqlite3_log(SQLITE_ERROR, 
            "Bitvec: pAllRead size is %d, dbOrigSize set to %d", 
            (int)sqlite3BitvecSize(pPager->pAllRead), pPager->dbSize
        );
      }
#endif
      pPager->eState = PAGER_WRITER_LOCKED;
      pPager->dbHintSize = pPager->dbSize;
      pPager->dbFileSize = pPager->dbSize;
      pPager->dbOrigSize = pPager->dbSize;
      pPager->journalOff = 0;
    }