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

Overview
Comment:Fix a race condition between flushing an in-memory tree to disk and opening a read-transaction.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | multi-process
Files: files | file ages | folders
SHA1: 6ced48df303d83a2e993bf070e92614d1578832d
User & Date: dan 2012-09-03 11:34:35.965
Context
2012-09-03
14:50
Fix a problem with growing the database file in mmap mode. check-in: 1a86aa1c6b user: dan tags: multi-process
11:34
Fix a race condition between flushing an in-memory tree to disk and opening a read-transaction. check-in: 6ced48df30 user: dan tags: multi-process
2012-09-02
09:25
Fix a crash in multi-threaded tests that can occur if a call to lsm_open() fails. check-in: dd2489a645 user: dan tags: multi-process
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/lsm_main.c.
714
715
716
717
718
719
720

721
722
723
724
725
726
727
  if( iLevel<0 ) iLevel = LSM_MAX(0, pDb->nTransOpen - 1);

  if( iLevel<pDb->nTransOpen ){
    if( iLevel==0 ){

      /* Commit the transaction to disk. */
      if( lsmTreeSize(pDb)>pDb->nTreeLimit ){

        bFlush = 1;
        rc = lsmFlushToDisk(pDb);
      }
      if( rc==LSM_OK ) rc = lsmLogCommit(pDb);
      if( rc==LSM_OK && pDb->eSafety==LSM_SAFETY_FULL ){
        rc = lsmFsSyncLog(pDb->pFS);
      }







>







714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
  if( iLevel<0 ) iLevel = LSM_MAX(0, pDb->nTransOpen - 1);

  if( iLevel<pDb->nTransOpen ){
    if( iLevel==0 ){

      /* Commit the transaction to disk. */
      if( lsmTreeSize(pDb)>pDb->nTreeLimit ){
        lsmTreeEndTransaction(pDb, 1);
        bFlush = 1;
        rc = lsmFlushToDisk(pDb);
      }
      if( rc==LSM_OK ) rc = lsmLogCommit(pDb);
      if( rc==LSM_OK && pDb->eSafety==LSM_SAFETY_FULL ){
        rc = lsmFsSyncLog(pDb->pFS);
      }
Changes to src/lsm_shared.c.
610
611
612
613
614
615
616

617
618
619
620
621
622
623
    if( rc==LSM_OK ){
      ShmHeader *pShm = pDb->pShmhdr;
      i64 iTree = pDb->treehdr.iTreeId;
      i64 iSnap = lsmCheckpointId(pDb->aSnapshot, 0);
      rc = lsmReadlock(pDb, iSnap, iTree);
      if( rc==LSM_OK ){
        if( (i64)pShm->hdr1.iTreeId==iTree 

         && lsmCheckpointId(pShm->aClient, 0)==iSnap
        ){
          /* Read lock has been successfully obtained. Deserialize the 
          ** checkpoint just loaded. TODO: This will be removed after 
          ** lsm_sorted.c is changed to work directly from the serialized
          ** version of the snapshot.  */
          rc = lsmCheckpointDeserialize(pDb, 0, pDb->aSnapshot, &pDb->pClient);







>







610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
    if( rc==LSM_OK ){
      ShmHeader *pShm = pDb->pShmhdr;
      i64 iTree = pDb->treehdr.iTreeId;
      i64 iSnap = lsmCheckpointId(pDb->aSnapshot, 0);
      rc = lsmReadlock(pDb, iSnap, iTree);
      if( rc==LSM_OK ){
        if( (i64)pShm->hdr1.iTreeId==iTree 
         && pShm->hdr1.iTransId==pDb->treehdr.iTransId
         && lsmCheckpointId(pShm->aClient, 0)==iSnap
        ){
          /* Read lock has been successfully obtained. Deserialize the 
          ** checkpoint just loaded. TODO: This will be removed after 
          ** lsm_sorted.c is changed to work directly from the serialized
          ** version of the snapshot.  */
          rc = lsmCheckpointDeserialize(pDb, 0, pDb->aSnapshot, &pDb->pClient);