SQLite4
Check-in [6e5e429ea7]
Not logged in

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

Overview
Comment:Fix a problem in the lsm_info(LOG_STRUCTURE) command causing errors in tcl tests.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6e5e429ea72004d4265ce85e9c776dc70e13f46d
User & Date: dan 2012-09-12 17:23:32
Context
2012-09-13
15:24
Add lsmtest tests that focus on recovering from the failure of a writer process. And fixes for the same. check-in: bb42813797 user: dan tags: trunk
2012-09-12
17:23
Fix a problem in the lsm_info(LOG_STRUCTURE) command causing errors in tcl tests. check-in: 6e5e429ea7 user: dan tags: trunk
16:19
Change the way worker clients keep snapshots consistent so as to match the description in lsm.wiki. check-in: 0427b07c14 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/lsmInt.h.

   727    727   int lsmLogWrite(lsm_db *, void *, int, void *, int);
   728    728   int lsmLogCommit(lsm_db *);
   729    729   void lsmLogEnd(lsm_db *pDb, int bCommit);
   730    730   void lsmLogTell(lsm_db *, LogMark *);
   731    731   void lsmLogSeek(lsm_db *, LogMark *);
   732    732   
   733    733   int lsmLogRecover(lsm_db *);
   734         -int lsmLogStructure(lsm_db *pDb, char **pzVal);
          734  +int lsmInfoLogStructure(lsm_db *pDb, char **pzVal);
   735    735   
   736    736   
   737    737   /**************************************************************************
   738    738   ** Functions from file "lsm_shared.c".
   739    739   */
   740    740   
   741    741   int lsmDbDatabaseConnect(lsm_db*, const char *);

Changes to src/lsm_log.c.

   740    740     pLog->cksum1 = pMark->cksum1;
   741    741   
   742    742     if( pMark->iOff > pLog->iRegion1End ) pLog->iRegion1End = 0;
   743    743     if( pMark->iOff > pLog->iRegion2Start ) pLog->iRegion2Start = 0;
   744    744   }
   745    745   
   746    746   /*
   747         -** TODO: Thread safety of this function?
          747  +** This function does the work for an lsm_info(LOG_STRUCTURE) request.
   748    748   */
   749         -int lsmLogStructure(lsm_db *pDb, char **pzVal){
   750         -  DbLog *pLog = &pDb->treehdr.log;
   751         -  *pzVal = lsmMallocPrintf(pDb->pEnv, 
   752         -      "%d %d %d %d %d %d", 
   753         -      (int)pLog->aRegion[0].iStart, (int)pLog->aRegion[0].iEnd,
   754         -      (int)pLog->aRegion[1].iStart, (int)pLog->aRegion[1].iEnd,
   755         -      (int)pLog->aRegion[2].iStart, (int)pLog->aRegion[2].iEnd
   756         -  );
   757         -  return (*pzVal ? LSM_OK : LSM_NOMEM_BKPT);
          749  +int lsmInfoLogStructure(lsm_db *pDb, char **pzVal){
          750  +  int rc = LSM_OK;
          751  +  char *zVal = 0;
          752  +
          753  +  /* If there is no read or write transaction open, read the latest 
          754  +  ** tree-header from shared-memory to report on. If necessary, update
          755  +  ** it based on the contents of the database header.  
          756  +  **
          757  +  ** No locks are taken here - these are passive read operations only.
          758  +  */
          759  +  if( pDb->pCsr==0 && pDb->nTransOpen==0 ){
          760  +    rc = lsmTreeLoadHeader(pDb, 0);
          761  +    if( rc==LSM_OK ) rc = logReclaimSpace(pDb);
          762  +  }
          763  +
          764  +  if( rc==LSM_OK ){
          765  +    DbLog *pLog = &pDb->treehdr.log;
          766  +    zVal = lsmMallocPrintf(pDb->pEnv, 
          767  +        "%d %d %d %d %d %d", 
          768  +        (int)pLog->aRegion[0].iStart, (int)pLog->aRegion[0].iEnd,
          769  +        (int)pLog->aRegion[1].iStart, (int)pLog->aRegion[1].iEnd,
          770  +        (int)pLog->aRegion[2].iStart, (int)pLog->aRegion[2].iEnd
          771  +    );
          772  +    if( !zVal ) rc = LSM_NOMEM_BKPT;
          773  +  }
          774  +
          775  +  *pzVal = zVal;
          776  +  return rc;
   758    777   }
   759    778   
   760    779   /*************************************************************************
   761    780   ** Begin code for log recovery.
   762    781   */
   763    782   
   764    783   typedef struct LogReader LogReader;

Changes to src/lsm_main.c.

   477    477         char **pzVal = va_arg(ap, char **);
   478    478         rc = lsmInfoPageDump(pDb, pgno, (eParam==LSM_INFO_PAGE_HEX_DUMP), pzVal);
   479    479         break;
   480    480       }
   481    481   
   482    482       case LSM_INFO_LOG_STRUCTURE: {
   483    483         char **pzVal = va_arg(ap, char **);
   484         -      rc = lsmLogStructure(pDb, pzVal);
          484  +      rc = lsmInfoLogStructure(pDb, pzVal);
   485    485         break;
   486    486       }
   487    487   
   488    488       default:
   489    489         rc = LSM_MISUSE;
   490    490         break;
   491    491     }

Changes to test/log2.test.

   100    100     execsql { INSERT INTO t1 VALUES(randstr(10,10), randstr(100, 100)) }
   101    101     execsql { INSERT INTO t1 VALUES(randstr(10,10), randstr(100, 100)) }
   102    102     execsql { INSERT INTO t1 VALUES(randstr(10,10), randstr(100, 100)) }
   103    103     execsql COMMIT
   104    104   } {}
   105    105   do_test         3.11 { 
   106    106     sqlite4_lsm_info db main log-structure 
   107         -} {1124 1271 0 1062 1272 1809}
          107  +} {0 0 139 1062 1272 1809}
   108    108   do_recover_test 3.12 { SELECT * FROM t1 } [execsql {SELECT * FROM t1}]
   109    109   
   110    110   #-------------------------------------------------------------------------
   111    111   #
   112    112   reset_db
   113    113   do_execsql_test 4.1 {
   114    114     CREATE TABLE t1(a PRIMARY KEY, b);