From 1290733ed9428de5b707b4f5607222c6ba0b04c3 Mon Sep 17 00:00:00 2001 From: Dwight Date: Wed, 4 Feb 2009 13:53:08 -0500 Subject: [PATCH] some debug logging --- SConstruct | 1 + db/instance.cpp | 3 +++ db/storage.cpp | 8 ++++++++ 3 files changed, 12 insertions(+) diff --git a/SConstruct b/SConstruct index 26d9cdbdc2e..62da201f873 100644 --- a/SConstruct +++ b/SConstruct @@ -92,6 +92,7 @@ AddOption( "--noOptimization", env = Environment() +env.Append( CPPDEFINES=[ "_RECSTORE" ] ) env.Append( CPPPATH=[ "." ] ) diff --git a/db/instance.cpp b/db/instance.cpp index 1fa357f48da..4c4f3a578ec 100644 --- a/db/instance.cpp +++ b/db/instance.cpp @@ -644,7 +644,10 @@ namespace mongo { stringstream ss3; MemoryMappedFile::closeAllFiles( ss3 ); rawOut( ss3.str() ); + + // should we be locked here? we aren't. might be ok as-is. recCacheCloseAll(); + rawOut( "dbexit: really exiting now\n" ); ::exit(rc); } diff --git a/db/storage.cpp b/db/storage.cpp index 219f5c471a0..6d1acbcb948 100644 --- a/db/storage.cpp +++ b/db/storage.cpp @@ -24,8 +24,11 @@ RecCache BasicCached_RecStore::rc(BucketSize); // Currently only called on program exit. void recCacheCloseAll() { #if defined(_RECSTORE) + assert( dbMutexInfo.isLocked() ); + (cout << "TEMP: writing dirty pages...\n").flush(); BasicCached_RecStore::rc.writeDirty( true ); RecCache::tempStore.flush(); + (cout << "TEMP: write dirty done\n").flush(); #endif } @@ -68,8 +71,11 @@ void BasicRecStore::init(const char *fn, unsigned recsize) /* -------------------------------------------------------- */ +int ndirtywritten; + inline void RecCache::writeIfDirty(Node *n) { if( n->dirty ) { + ndirtywritten++; n->dirty = false; tempStore.update(fileOfs(n->loc), n->data, recsize); } @@ -78,11 +84,13 @@ inline void RecCache::writeIfDirty(Node *n) { /* note that this is written in order, as much as possible, given that dirtyl is of type set. */ void RecCache::writeDirty( bool rawLog ) { try { + ndirtywritten=0; for( set::iterator i = dirtyl.begin(); i != dirtyl.end(); i++ ) { map::iterator j = m.find(*i); if( j != m.end() ) writeIfDirty(j->second); } + out() << "TEMP: ndirtywritten: " << ndirtywritten << endl; } catch(...) { const char *message = "Problem: bad() in RecCache::writeDirty, file io error\n";