/ Check-in [f7e3e2bc]
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:Generate extra log messages in response to irregularites in the pointer-map used by "BEGIN CONCURRENT" transactions.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | begin-concurrent
Files: files | file ages | folders
SHA3-256: f7e3e2bc88f110d9282ce5d2fa58580c585faeb57cb707253f05001e5f4bd91b
User & Date: dan 2017-05-31 17:06:13
Wiki:begin-concurrent
Context
2017-06-02
09:31
Extend even further the logging designed to find problems in the pointer-map structure. Call abort() to dump a core as soon as such a problem is seen. check-in: f131677d user: dan tags: begin-concurrent
2017-05-31
17:06
Generate extra log messages in response to irregularites in the pointer-map used by "BEGIN CONCURRENT" transactions. check-in: f7e3e2bc user: dan tags: begin-concurrent
2017-05-29
19:23
Instead of a root page number, log the object (table or index) name if a page level locking conflict is detected. check-in: 9ad846e5 user: dan tags: begin-concurrent
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to src/btree.c.

   625    625       sqlite3_free(pMap->aRollback);
   626    626       sqlite3_free(pMap->aPtr);
   627    627       sqlite3_free(pMap->aSvpt);
   628    628       sqlite3_free(pMap);
   629    629       pBt->pMap = 0;
   630    630     }
   631    631   }
          632  +
          633  +static void btreeCheckPtrmap(BtShared *p, int nPage, const char *zLog){
          634  +  BtreePtrmap *pMap = p->pMap;
          635  +  if( pMap ){
          636  +    int n = MIN(1 + nPage - (int)pMap->iFirst, 5);
          637  +    int i;
          638  +    for(i=0; i<n; i++){
          639  +      int eType = pMap->aPtr[i].eType;
          640  +      if( (eType==PTRMAP_OVERFLOW1 || 
          641  +            eType==PTRMAP_OVERFLOW2 || 
          642  +            eType==PTRMAP_BTREE) && pMap->aPtr[i].parent==0 
          643  +        ){
          644  +        sqlite3_log(SQLITE_ERROR, 
          645  +            "Bitvec: error at (%s) - (%d/%d %d/%d %d/%d %d/%d %d/%d)",
          646  +            zLog,
          647  +            (int)pMap->aPtr[0].eType, (int)pMap->aPtr[0].parent,
          648  +            (n>1 ? (int)pMap->aPtr[1].eType : -1),
          649  +            (n>1 ? (int)pMap->aPtr[1].parent : -1),
          650  +
          651  +            (n>2 ? (int)pMap->aPtr[2].eType : -1),
          652  +            (n>2 ? (int)pMap->aPtr[2].parent : -1),
          653  +
          654  +            (n>3 ? (int)pMap->aPtr[3].eType : -1),
          655  +            (n>3 ? (int)pMap->aPtr[3].parent : -1),
          656  +
          657  +            (n>4 ? (int)pMap->aPtr[4].eType : -1),
          658  +            (n>4 ? (int)pMap->aPtr[4].parent : -1)
          659  +            );
          660  +        break;
          661  +      }
          662  +    }
          663  +  }
          664  +}
   632    665   #else  /* SQLITE_OMIT_CONCURRENT */
   633    666   # define btreePtrmapAllocate(x) SQLITE_OK
   634    667   # define btreePtrmapDelete(x) 
   635    668   # define btreePtrmapBegin(x,y)  SQLITE_OK
   636    669   # define btreePtrmapEnd(x,y,z) 
          670  +# define btreeCheckPtrmap(a,b,c)
   637    671   #endif /* SQLITE_OMIT_CONCURRENT */
   638    672   
   639    673   static void releasePage(MemPage *pPage);  /* Forward reference */
   640    674   
   641    675   /*
   642    676   ***** This routine is used inside of assert() only ****
   643    677   **
................................................................................
  4083   4117     /* If page 1 of the database is not writable, then no pages were allocated
  4084   4118     ** or freed by this transaction. In this case no special handling is 
  4085   4119     ** required. Otherwise, if page 1 is dirty, proceed.  */
  4086   4120     BtreePtrmap *pMap = pBt->pMap;
  4087   4121     Pgno iTrunk = get4byte(&p1[32]);
  4088   4122     Pgno nPage = btreePagecount(pBt);
  4089   4123     u32 nFree = get4byte(&p1[36]);
         4124  +
         4125  +  btreeCheckPtrmap(pBt, nPage, "btreeFixUnlocked(1)");
  4090   4126   
  4091   4127     assert( pBt->pMap );
  4092   4128     rc = sqlite3PagerUpgradeSnapshot(pPager, pPage1->pDbPage);
  4093   4129     assert( p1==pPage1->aData );
  4094   4130   
  4095   4131     if( rc==SQLITE_OK ){
  4096   4132       Pgno nHPage = get4byte(&p1[28]);
................................................................................
  8670   8706         pCur->eState = CURSOR_REQUIRESEEK;
  8671   8707         pCur->nKey = pX->nKey;
  8672   8708       }
  8673   8709     }
  8674   8710     assert( pCur->apPage[pCur->iPage]->nOverflow==0 );
  8675   8711   
  8676   8712   end_insert:
         8713  +  btreeCheckPtrmap(pBt, pBt->nPage, "sqlite3BtreeInsert()");
  8677   8714     return rc;
  8678   8715   }
  8679   8716   
  8680   8717   /*
  8681   8718   ** Delete the entry that the cursor is pointing to. 
  8682   8719   **
  8683   8720   ** If the BTREE_SAVEPOSITION bit of the flags parameter is zero, then
................................................................................
  8841   8878       }else{
  8842   8879         rc = moveToRoot(pCur);
  8843   8880         if( bPreserve ){
  8844   8881           pCur->eState = CURSOR_REQUIRESEEK;
  8845   8882         }
  8846   8883       }
  8847   8884     }
         8885  +  btreeCheckPtrmap(pBt, pBt->nPage, "sqlite3BtreeInsert()");
  8848   8886     return rc;
  8849   8887   }
  8850   8888   
  8851   8889   /*
  8852   8890   ** Create a new BTree table.  Write into *piTable the page
  8853   8891   ** number for the root page of the new table.
  8854   8892   **

Changes to test/concurrent3.test.

    22     22   ifcapable !concurrent {
    23     23     finish_test
    24     24     return
    25     25   }
    26     26   
    27     27   db close
    28     28   sqlite3_shutdown
    29         -#test_sqlite3_log xLog
    30         -#proc xLog {error_code msg} { puts "$error_code: $msg" }
           29  +test_sqlite3_log xLog
           30  +proc xLog {error_code msg} { puts "$error_code: $msg" }
    31     31   reset_db
    32     32   
    33     33   proc create_schema {} {
    34     34     db eval {
    35     35       PRAGMA journal_mode = wal;
    36     36   
    37     37       CREATE TABLE t1(x, y);