SQLite4
Check-in [d409cd8c8a]
Not logged in

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

Overview
Comment:Fix a bug causing an infinite loop if there are open cursors when the in-memory tree is flushed to disk.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | embedded-btree
Files: files | file ages | folders
SHA1: d409cd8c8a5aff705f5299994276194cf7262b0f
User & Date: dan 2012-06-26 19:45:41
Context
2012-06-26
20:39
Merge trunk changes. check-in: 209c12ae0b user: dan tags: embedded-btree
19:45
Fix a bug causing an infinite loop if there are open cursors when the in-memory tree is flushed to disk. check-in: d409cd8c8a user: dan tags: embedded-btree
18:10
Fix another problem with mmap and using a background thread. check-in: ec39163b79 user: dan tags: embedded-btree
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/lsm_sorted.c.

2001
2002
2003
2004
2005
2006
2007




2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
....
2663
2664
2665
2666
2667
2668
2669

2670
2671
2672
2673



2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
....
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
  MultiCursor **ppCsr             /* OUT: Allocated cursor */
){
  int rc = LSM_OK;                /* Return Code */
  MultiCursor *pCsr = *ppCsr;     /* Allocated multi-cursor */

  if( pCsr==0 ){
    pCsr = (MultiCursor *)lsmMallocZeroRc(pDb->pEnv, sizeof(MultiCursor), &rc);




  }

  if( rc==LSM_OK ){
    if( useTree ){
      assert( pDb->pTV );
      rc = lsmTreeCursorNew(pDb, &pCsr->pTreeCsr);
    }
    pCsr->pDb = pDb;
    pCsr->pSnap = pSnap;
    pCsr->xCmp = pDb->xCmp;
    if( bUserOnly ){
      pCsr->flags |= CURSOR_IGNORE_SYSTEM;
    }

    pCsr->pNext = pDb->pCsr;
    pDb->pCsr = pCsr;
  }
  if( rc!=LSM_OK ){
    lsmMCursorClose(pCsr);
    pCsr = 0;
  }
  *ppCsr = pCsr;
  return rc;
................................................................................
  int nVal;
  int rc;

  assert( pCsr->aTree );
  assert( rtIsDelete(pCsr->eType)==0 || !(pCsr->flags & CURSOR_IGNORE_DELETE) );

  rc = multiCursorGetVal(pCsr, pCsr->aTree[1], &pVal, &nVal);

  if( rc==LSM_OK ) rc = sortedBlobSet(pCsr->pDb->pEnv, &pCsr->val, pVal, nVal);
  if( rc==LSM_OK ){
    pVal = pCsr->val.pData;
  }else{



    pVal = 0;
    nVal = 0;
  }

  *ppVal = pVal;
  *pnVal = nVal;
  return rc;
}

int lsmMCursorType(MultiCursor *pCsr, int *peType){
  assert( pCsr->aTree );
................................................................................

  if( rc==LSM_OK && nPage>0 ){
    int bOptimize = ((flags & LSM_WORK_OPTIMIZE) ? 1 : 0);
    int nWrite = 0;
    pDb->pWorker = lsmDbSnapshotWorker(pDb);
    rc = sortedWork(pDb, nPage, bOptimize, &nWrite);

#if 0
    if( nWrite && (flags & LSM_WORK_CHECKPOINT) ){
      int nHdrLevel = 0;
      if( rc==LSM_OK ) rc = lsmSortedFlushDb(pDb);
      if( rc==LSM_OK ) rc = lsmSortedNewToplevel(pDb, &nHdrLevel);
      if( rc==LSM_OK ) rc = lsmDbUpdateClient(pDb, nHdrLevel);
    }
#endif

    lsmDbSnapshotRelease(pDb->pEnv, pDb->pWorker);
    pDb->pWorker = 0;
    if( pnWrite ) *pnWrite = nWrite;
  }else if( pnWrite ){
    *pnWrite = 0;
  }







>
>
>
>













<
<
<







 







>
|
<

<
>
>
>



<







 







<






<







2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024



2025
2026
2027
2028
2029
2030
2031
....
2664
2665
2666
2667
2668
2669
2670
2671
2672

2673

2674
2675
2676
2677
2678
2679

2680
2681
2682
2683
2684
2685
2686
....
4215
4216
4217
4218
4219
4220
4221

4222
4223
4224
4225
4226
4227

4228
4229
4230
4231
4232
4233
4234
  MultiCursor **ppCsr             /* OUT: Allocated cursor */
){
  int rc = LSM_OK;                /* Return Code */
  MultiCursor *pCsr = *ppCsr;     /* Allocated multi-cursor */

  if( pCsr==0 ){
    pCsr = (MultiCursor *)lsmMallocZeroRc(pDb->pEnv, sizeof(MultiCursor), &rc);
    if( pCsr ){
      pCsr->pNext = pDb->pCsr;
      pDb->pCsr = pCsr;
    }
  }

  if( rc==LSM_OK ){
    if( useTree ){
      assert( pDb->pTV );
      rc = lsmTreeCursorNew(pDb, &pCsr->pTreeCsr);
    }
    pCsr->pDb = pDb;
    pCsr->pSnap = pSnap;
    pCsr->xCmp = pDb->xCmp;
    if( bUserOnly ){
      pCsr->flags |= CURSOR_IGNORE_SYSTEM;
    }



  }
  if( rc!=LSM_OK ){
    lsmMCursorClose(pCsr);
    pCsr = 0;
  }
  *ppCsr = pCsr;
  return rc;
................................................................................
  int nVal;
  int rc;

  assert( pCsr->aTree );
  assert( rtIsDelete(pCsr->eType)==0 || !(pCsr->flags & CURSOR_IGNORE_DELETE) );

  rc = multiCursorGetVal(pCsr, pCsr->aTree[1], &pVal, &nVal);
  if( pVal && rc==LSM_OK ){
    rc = sortedBlobSet(pCsr->pDb->pEnv, &pCsr->val, pVal, nVal);

    pVal = pCsr->val.pData;

  }

  if( rc!=LSM_OK ){
    pVal = 0;
    nVal = 0;
  }

  *ppVal = pVal;
  *pnVal = nVal;
  return rc;
}

int lsmMCursorType(MultiCursor *pCsr, int *peType){
  assert( pCsr->aTree );
................................................................................

  if( rc==LSM_OK && nPage>0 ){
    int bOptimize = ((flags & LSM_WORK_OPTIMIZE) ? 1 : 0);
    int nWrite = 0;
    pDb->pWorker = lsmDbSnapshotWorker(pDb);
    rc = sortedWork(pDb, nPage, bOptimize, &nWrite);


    if( nWrite && (flags & LSM_WORK_CHECKPOINT) ){
      int nHdrLevel = 0;
      if( rc==LSM_OK ) rc = lsmSortedFlushDb(pDb);
      if( rc==LSM_OK ) rc = lsmSortedNewToplevel(pDb, &nHdrLevel);
      if( rc==LSM_OK ) rc = lsmDbUpdateClient(pDb, nHdrLevel);
    }


    lsmDbSnapshotRelease(pDb->pEnv, pDb->pWorker);
    pDb->pWorker = 0;
    if( pnWrite ) *pnWrite = nWrite;
  }else if( pnWrite ){
    *pnWrite = 0;
  }