fix bug when we nuke a collnum

from a tree right in the middle of when
saving rdb trees in process.cpp.
This commit is contained in:
Matt Wells 2013-10-30 12:27:08 -07:00
parent fe2144d13d
commit b83dd59913
4 changed files with 18 additions and 1 deletions

View File

@ -591,6 +591,9 @@ bool Collectiondb::deleteRec ( char *coll , bool deleteTurkdb ) {
sc->m_lastDownloadCache.clear(collnum);
*/
// CAUTION: tree might be in the middle of saving
// we deal with this in Process.cpp now
// remove from spider cache, tell it to sync up with collectiondb
//g_spiderCache.reset1();
// . TODO: remove from g_sync
@ -796,6 +799,9 @@ bool Collectiondb::resetColl ( char *coll , bool resetTurkdb ) {
// right now we #define collnum_t short
if ( m_numRecs > 0x7fff ) { char *xx=NULL;*xx=0; }
// CAUTION: tree might be in the middle of saving
// we deal with this in Process.cpp now
// . unlink all the *.dat and *.map files for this coll in its subdir
// . remove all recs from this collnum from m_tree/m_buckets
// . updates RdbBase::m_collnum

View File

@ -1497,7 +1497,11 @@ bool Process::saveRdbTrees ( bool useThread ) {
// check if any need to finish saving
for ( long i = 0 ; i < m_numRdbs ; i++ ) {
Rdb *rdb = m_rdbs[i];
if ( rdb->needsSave ( ) ) return false;
//if ( rdb->needsSave ( ) ) return false;
// we disable the tree while saving so we can't really add recs
// to one rdb tree while saving, but for crawlbot
// we might have added or deleted collections.
if ( rdb->isSavingTree ( ) ) return false;
}
// . check spider cache files (doleiptable waitingtree etc.)

View File

@ -879,6 +879,11 @@ void Rdb::doneSaving ( ) {
//if ( m_isClosing ) close ( );
}
bool Rdb::isSavingTree ( ) {
if ( m_useTree ) return m_tree.m_isSaving;
return m_buckets.m_isSaving;
}
bool Rdb::saveTree ( bool useThread ) {
char *dbn = m_dbname;
if ( ! dbn ) dbn = "unknown";

2
Rdb.h
View File

@ -271,6 +271,8 @@ class Rdb {
// . you'll lose your data in this class if you call this
void reset();
bool isSavingTree ( ) ;
bool saveTree ( bool useThread ) ;
bool saveMaps ( bool useThread ) ;
//bool saveCache ( bool useThread ) ;