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 Unified Diffs Show Whitespace Changes Patch

Changes to src/lsmInt.h.

727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
int lsmLogWrite(lsm_db *, void *, int, void *, int);
int lsmLogCommit(lsm_db *);
void lsmLogEnd(lsm_db *pDb, int bCommit);
void lsmLogTell(lsm_db *, LogMark *);
void lsmLogSeek(lsm_db *, LogMark *);

int lsmLogRecover(lsm_db *);
int lsmLogStructure(lsm_db *pDb, char **pzVal);


/**************************************************************************
** Functions from file "lsm_shared.c".
*/

int lsmDbDatabaseConnect(lsm_db*, const char *);







|







727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
int lsmLogWrite(lsm_db *, void *, int, void *, int);
int lsmLogCommit(lsm_db *);
void lsmLogEnd(lsm_db *pDb, int bCommit);
void lsmLogTell(lsm_db *, LogMark *);
void lsmLogSeek(lsm_db *, LogMark *);

int lsmLogRecover(lsm_db *);
int lsmInfoLogStructure(lsm_db *pDb, char **pzVal);


/**************************************************************************
** Functions from file "lsm_shared.c".
*/

int lsmDbDatabaseConnect(lsm_db*, const char *);

Changes to src/lsm_log.c.

740
741
742
743
744
745
746
747
748
749















750
751
752
753
754
755
756
757




758
759
760
761
762
763
764
  pLog->cksum1 = pMark->cksum1;

  if( pMark->iOff > pLog->iRegion1End ) pLog->iRegion1End = 0;
  if( pMark->iOff > pLog->iRegion2Start ) pLog->iRegion2Start = 0;
}

/*
** TODO: Thread safety of this function?
*/
int lsmLogStructure(lsm_db *pDb, char **pzVal){















  DbLog *pLog = &pDb->treehdr.log;
  *pzVal = lsmMallocPrintf(pDb->pEnv, 
      "%d %d %d %d %d %d", 
      (int)pLog->aRegion[0].iStart, (int)pLog->aRegion[0].iEnd,
      (int)pLog->aRegion[1].iStart, (int)pLog->aRegion[1].iEnd,
      (int)pLog->aRegion[2].iStart, (int)pLog->aRegion[2].iEnd
  );
  return (*pzVal ? LSM_OK : LSM_NOMEM_BKPT);




}

/*************************************************************************
** Begin code for log recovery.
*/

typedef struct LogReader LogReader;







|

|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|





|
>
>
>
>







740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
  pLog->cksum1 = pMark->cksum1;

  if( pMark->iOff > pLog->iRegion1End ) pLog->iRegion1End = 0;
  if( pMark->iOff > pLog->iRegion2Start ) pLog->iRegion2Start = 0;
}

/*
** This function does the work for an lsm_info(LOG_STRUCTURE) request.
*/
int lsmInfoLogStructure(lsm_db *pDb, char **pzVal){
  int rc = LSM_OK;
  char *zVal = 0;

  /* If there is no read or write transaction open, read the latest 
  ** tree-header from shared-memory to report on. If necessary, update
  ** it based on the contents of the database header.  
  **
  ** No locks are taken here - these are passive read operations only.
  */
  if( pDb->pCsr==0 && pDb->nTransOpen==0 ){
    rc = lsmTreeLoadHeader(pDb, 0);
    if( rc==LSM_OK ) rc = logReclaimSpace(pDb);
  }

  if( rc==LSM_OK ){
    DbLog *pLog = &pDb->treehdr.log;
    zVal = lsmMallocPrintf(pDb->pEnv, 
        "%d %d %d %d %d %d", 
        (int)pLog->aRegion[0].iStart, (int)pLog->aRegion[0].iEnd,
        (int)pLog->aRegion[1].iStart, (int)pLog->aRegion[1].iEnd,
        (int)pLog->aRegion[2].iStart, (int)pLog->aRegion[2].iEnd
    );
    if( !zVal ) rc = LSM_NOMEM_BKPT;
  }

  *pzVal = zVal;
  return rc;
}

/*************************************************************************
** Begin code for log recovery.
*/

typedef struct LogReader LogReader;

Changes to src/lsm_main.c.

477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
      char **pzVal = va_arg(ap, char **);
      rc = lsmInfoPageDump(pDb, pgno, (eParam==LSM_INFO_PAGE_HEX_DUMP), pzVal);
      break;
    }

    case LSM_INFO_LOG_STRUCTURE: {
      char **pzVal = va_arg(ap, char **);
      rc = lsmLogStructure(pDb, pzVal);
      break;
    }

    default:
      rc = LSM_MISUSE;
      break;
  }







|







477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
      char **pzVal = va_arg(ap, char **);
      rc = lsmInfoPageDump(pDb, pgno, (eParam==LSM_INFO_PAGE_HEX_DUMP), pzVal);
      break;
    }

    case LSM_INFO_LOG_STRUCTURE: {
      char **pzVal = va_arg(ap, char **);
      rc = lsmInfoLogStructure(pDb, pzVal);
      break;
    }

    default:
      rc = LSM_MISUSE;
      break;
  }

Changes to test/log2.test.

100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
  execsql { INSERT INTO t1 VALUES(randstr(10,10), randstr(100, 100)) }
  execsql { INSERT INTO t1 VALUES(randstr(10,10), randstr(100, 100)) }
  execsql { INSERT INTO t1 VALUES(randstr(10,10), randstr(100, 100)) }
  execsql COMMIT
} {}
do_test         3.11 { 
  sqlite4_lsm_info db main log-structure 
} {1124 1271 0 1062 1272 1809}
do_recover_test 3.12 { SELECT * FROM t1 } [execsql {SELECT * FROM t1}]

#-------------------------------------------------------------------------
#
reset_db
do_execsql_test 4.1 {
  CREATE TABLE t1(a PRIMARY KEY, b);







|







100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
  execsql { INSERT INTO t1 VALUES(randstr(10,10), randstr(100, 100)) }
  execsql { INSERT INTO t1 VALUES(randstr(10,10), randstr(100, 100)) }
  execsql { INSERT INTO t1 VALUES(randstr(10,10), randstr(100, 100)) }
  execsql COMMIT
} {}
do_test         3.11 { 
  sqlite4_lsm_info db main log-structure 
} {0 0 139 1062 1272 1809}
do_recover_test 3.12 { SELECT * FROM t1 } [execsql {SELECT * FROM t1}]

#-------------------------------------------------------------------------
#
reset_db
do_execsql_test 4.1 {
  CREATE TABLE t1(a PRIMARY KEY, b);