Test auto-vacuum mode for crash-proofness. Also fix a bug related to the same. (CVS 2077)
FossilOrigin-Name: 839ad771a6e781426c0fd624a4d1c91a5fcf8546
This commit is contained in:
+1
-5
@@ -9,7 +9,7 @@
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** $Id: btree.c,v 1.214 2004/11/08 07:13:14 danielk1977 Exp $
|
||||
** $Id: btree.c,v 1.215 2004/11/08 09:26:09 danielk1977 Exp $
|
||||
**
|
||||
** This file implements a external (disk-based) database using BTrees.
|
||||
** For a detailed discussion of BTrees, refer to
|
||||
@@ -1825,9 +1825,6 @@ static int autoVacuumCommit(Btree *pBt, Pgno *nTrunc){
|
||||
*nTrunc = finSize;
|
||||
|
||||
autovacuum_out:
|
||||
/* TODO: A goto autovacuum_out; will fail to call releasePage() on
|
||||
** outstanding references. Fix.
|
||||
*/
|
||||
assert( nRef==*sqlite3pager_stats(pPager) );
|
||||
if( rc!=SQLITE_OK ){
|
||||
sqlite3pager_rollback(pPager);
|
||||
@@ -5267,7 +5264,6 @@ char *sqlite3BtreeIntegrityCheck(Btree *pBt, int *aRoot, int nRoot){
|
||||
for(i=0; i<nRoot; i++){
|
||||
if( aRoot[i]==0 ) continue;
|
||||
#ifndef SQLITE_OMIT_AUTOVACUUM
|
||||
/* Note: This is temporary code for use during development of auto-vacuum. */
|
||||
if( pBt->autoVacuum && aRoot[i]>1 ){
|
||||
checkPtrmap(&sCheck, aRoot[i], PTRMAP_ROOTPAGE, 0, 0);
|
||||
}
|
||||
|
||||
+26
-2
@@ -18,7 +18,7 @@
|
||||
** file simultaneously, or one process from reading the database while
|
||||
** another is writing.
|
||||
**
|
||||
** @(#) $Id: pager.c,v 1.175 2004/11/08 07:13:14 danielk1977 Exp $
|
||||
** @(#) $Id: pager.c,v 1.176 2004/11/08 09:26:10 danielk1977 Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "os.h"
|
||||
@@ -34,7 +34,7 @@
|
||||
#define TRACE2(X,Y) sqlite3DebugPrintf(X,Y)
|
||||
#define TRACE3(X,Y,Z) sqlite3DebugPrintf(X,Y,Z)
|
||||
#define TRACE4(X,Y,Z,W) sqlite3DebugPrintf(X,Y,Z,W)
|
||||
#define TRACE5(X,Y,Z,W,V) sqlite3DebugPrintf(X,Y,Z,W, V)
|
||||
#define TRACE5(X,Y,Z,W,V) sqlite3DebugPrintf(X,Y,Z,W,V)
|
||||
#else
|
||||
#define TRACE1(X)
|
||||
#define TRACE2(X,Y)
|
||||
@@ -3303,6 +3303,7 @@ int sqlite3pager_movepage(Pager *pPager, void *pData, Pgno pgno){
|
||||
PgHdr *pPg = DATA_TO_PGHDR(pData);
|
||||
PgHdr *pPgOld;
|
||||
int h;
|
||||
Pgno needSyncPgno = 0;
|
||||
|
||||
assert( !pPager->stmtInUse );
|
||||
assert( pPg->nRef>0 );
|
||||
@@ -3310,6 +3311,12 @@ int sqlite3pager_movepage(Pager *pPager, void *pData, Pgno pgno){
|
||||
TRACE5("MOVE %d page %d (needSync=%d) moves to %d\n",
|
||||
PAGERID(pPager), pPg->pgno, pPg->needSync, pgno);
|
||||
|
||||
if( pPg->needSync ){
|
||||
needSyncPgno = pPg->pgno;
|
||||
assert( pPg->inJournal );
|
||||
assert( pPg->dirty );
|
||||
}
|
||||
|
||||
/* Unlink pPg from it's hash-chain */
|
||||
unlinkHashChain(pPager, pPg);
|
||||
|
||||
@@ -3342,6 +3349,23 @@ int sqlite3pager_movepage(Pager *pPager, void *pData, Pgno pgno){
|
||||
pPg->dirty = 1;
|
||||
pPager->dirtyCache = 1;
|
||||
|
||||
if( needSyncPgno ){
|
||||
/* If needSyncPgno is non-zero, then the journal file needs to be
|
||||
** sync()ed before any data is written to database file page needSyncPgno.
|
||||
** Currently, no such page exists in the page-cache and the
|
||||
** Pager.aInJournal bit has been set. This needs to be remedied by loading
|
||||
** the page into the pager-cache and setting the PgHdr.needSync flag.
|
||||
*/
|
||||
int rc;
|
||||
void *pNeedSync;
|
||||
rc = sqlite3pager_get(pPager, needSyncPgno, &pNeedSync);
|
||||
if( rc!=SQLITE_OK ) return rc;
|
||||
DATA_TO_PGHDR(pNeedSync)->needSync = 1;
|
||||
DATA_TO_PGHDR(pNeedSync)->inJournal = 1;
|
||||
DATA_TO_PGHDR(pNeedSync)->dirty = 1;
|
||||
sqlite3pager_unref(pNeedSync);
|
||||
}
|
||||
|
||||
return SQLITE_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user