diff options
author | Dwight <dmerriman@gmail.com> | 2008-06-29 22:33:59 -0400 |
---|---|---|
committer | Dwight <dmerriman@gmail.com> | 2008-06-29 22:33:59 -0400 |
commit | 0bc5be592deca0fa4fa869931fd340035295d5c7 (patch) | |
tree | df2bd84e9a6511247b6df1c6712c28f3a4bfe0b9 /db | |
parent | d85e75b674f5ea45e936ca3a5409b54d937f361a (diff) | |
download | mongo-0bc5be592deca0fa4fa869931fd340035295d5c7.tar.gz |
validate a little smarter
Diffstat (limited to 'db')
-rw-r--r-- | db/db.cpp | 10 | ||||
-rw-r--r-- | db/namespace.h | 7 | ||||
-rw-r--r-- | db/query.cpp | 46 | ||||
-rw-r--r-- | db/storage.h | 6 |
4 files changed, 51 insertions, 18 deletions
diff --git a/db/db.cpp b/db/db.cpp index 130636ca23a..660b7b697ee 100644 --- a/db/db.cpp +++ b/db/db.cpp @@ -403,6 +403,7 @@ void jniCallback(Message& m, Message& out) bool log = false; curOp = m.data->operation; + if( m.data->operation == dbQuery ) { // on a query, the Message must have m.freeIt true so that the buffer data can be // retained by cursors. As freeIt is false, we make a copy here. @@ -511,6 +512,15 @@ void connThread() bool log = false; curOp = m.data->operation; + + /* use this if you only want to process operations for a particular namespace. maybe add to cmd line parms or a #define + DbMessage ddd(m); + if( strncmp(ddd.getns(), "grid", 4) != 0 ) { + cout << "TEMP skip " << ddd.getns() << '\n'; + } + else + */ + if( m.data->operation == dbMsg ) { ss << "msg "; char *p = m.data->_data; diff --git a/db/namespace.h b/db/namespace.h index 0854a666ed6..2c02662e26d 100644 --- a/db/namespace.h +++ b/db/namespace.h @@ -168,6 +168,13 @@ public: ht->put(n, details); } + /* just for diagnostics */ + size_t detailsOffset(NamespaceDetails *d) { + cout << d << ' ' << ht->nodes << endl; + cout << f.viewOfs() << endl; + return ((char *) d) - (char *) ht->nodes; + } + NamespaceDetails* details(const char *ns) { Namespace n(ns); return ht->get(n); diff --git a/db/query.cpp b/db/query.cpp index 7c90d232e9e..85941b64490 100644 --- a/db/query.cpp +++ b/db/query.cpp @@ -339,6 +339,7 @@ string validateNS(const char *ns, NamespaceDetails *d) { bool valid = true; stringstream ss; ss << "\nvalidate\n"; + ss << " details: " << hex << d << " ofs:" << nsindex(ns)->detailsOffset(d) << endl; if( d->capped ) ss << " capped:" << d->capped << " max:" << d->max << '\n'; @@ -347,11 +348,14 @@ string validateNS(const char *ns, NamespaceDetails *d) { ss << " padding:" << d->paddingFactor << '\n'; try { - { + try { ss << " first extent:\n"; d->firstExtent.ext()->dump(ss); valid = valid && d->firstExtent.ext()->validates(); } + catch(...) { + ss << "\n exception firstextent\n" << endl; + } auto_ptr<Cursor> c = theDataFileMgr.findAll(ns); int n = 0; @@ -388,21 +392,29 @@ string validateNS(const char *ns, NamespaceDetails *d) { int incorrect = 0; for( int i = 0; i < Buckets; i++ ) { DiskLoc loc = d->deletedList[i]; - while( !loc.isNull() ) { - if( recs.count(loc) ) - incorrect++; -// if( loc == DiskLoc(0, 0x476878) ) { -// cout << "********* target is in deleted list b:" << i << endl; -// } - ndel++; - DeletedRecord *d = loc.drec(); - delSize += d->lengthWithHeaders; - loc = d->nextDeleted; - } + try { + int k = 0; + while( !loc.isNull() ) { + if( recs.count(loc) ) + incorrect++; + ndel++; + + if( loc.questionable() ) { + ss << " ?bad deleted loc: " << loc.toString() << " bucket:" << i << " k:" << k << endl; + valid = false; + break; + } + + DeletedRecord *d = loc.drec(); + delSize += d->lengthWithHeaders; + loc = d->nextDeleted; + k++; + } + } catch(...) { ss <<" ?exception in deleted chain for bucket " << i << endl; valid = false; } } ss << " deleted: n: " << ndel << " size: " << delSize << '\n'; if( incorrect ) { - ss << " corrupt: " << incorrect << " records from datafile are in deleted list\n"; + ss << " ?corrupt: " << incorrect << " records from datafile are in deleted list\n"; valid = false; } @@ -410,24 +422,22 @@ string validateNS(const char *ns, NamespaceDetails *d) { try { ss << " nIndexes:" << d->nIndexes << endl; for( ; idxn < d->nIndexes; idxn++ ) { -//TEMP! -//cout << d->indexes[idxn].indexNamespace() << endl; ss << " " << d->indexes[idxn].indexNamespace() << " keys:" << d->indexes[idxn].head.btree()->fullValidate(d->indexes[idxn].head) << endl; } } catch(...) { - ss << "\n exception during index validate idxn:" << idxn << endl; + ss << "\n exception during index validate idxn:" << idxn << endl; valid=false; } } catch(AssertionException) { - ss << "\n exception during validate\n" << endl; + ss << "\n exception during validate\n" << endl; valid = false; } if( !valid ) - ss << " ns corrupt, requires dbchk\n"; + ss << " ns corrupt, requires dbchk\n"; return ss.str(); } diff --git a/db/storage.h b/db/storage.h index 3bd70604118..dd15a38df8e 100644 --- a/db/storage.h +++ b/db/storage.h @@ -30,6 +30,12 @@ public: DiskLoc(const DiskLoc& l) { fileNo=l.fileNo; ofs=l.ofs; } + bool questionable() { + return ofs < -1 || + fileNo < -1 || + fileNo > 20; + } + bool isNull() const { return ofs == NullOfs; } void Null() { fileNo = -1; ofs = NullOfs; } void setInvalid() { fileNo = -2; } |