summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwight <dmerriman@gmail.com>2008-06-25 19:41:30 -0400
committerDwight <dmerriman@gmail.com>2008-06-25 19:41:30 -0400
commit59a93423a940c65256efc544ca83d3e4616c31c2 (patch)
tree1ca5efce95f24aa08d54d3de3118b795128b22d1
parent3d428ce45949adf03d9478d4223db55238f08197 (diff)
downloadmongo-59a93423a940c65256efc544ca83d3e4616c31c2.tar.gz
better validation - check if things mistakenly in the free list
-rw-r--r--db/btree.cpp10
-rw-r--r--db/query.cpp25
2 files changed, 34 insertions, 1 deletions
diff --git a/db/btree.cpp b/db/btree.cpp
index 2cbfe9811b4..c4a36e2e0ea 100644
--- a/db/btree.cpp
+++ b/db/btree.cpp
@@ -59,6 +59,16 @@ int BucketBasics::fullValidate(const DiskLoc& thisLoc) {
for( int i = 0; i < n; i++ ) {
_KeyNode& kn = k(i);
+
+// TEMP!
+/* if( kn.recordLoc == DiskLoc(0, 0x476878) ) {
+ cout << "*** got target record\n ";
+ if( kn.isUnused() ) cout << " UNUSED!\n ";
+ KeyNode k = keyNode(i);
+ cout << k.key.toString();
+ cout << "\n i:" << i << endl;
+ }
+*/
if( kn.isUsed() ) kc++;
if( !kn.prevChildBucket.isNull() ) {
DiskLoc left = kn.prevChildBucket;
diff --git a/db/query.cpp b/db/query.cpp
index bb15791e8b5..cef5dbf50a9 100644
--- a/db/query.cpp
+++ b/db/query.cpp
@@ -355,8 +355,18 @@ string validateNS(const char *ns, NamespaceDetails *d) {
int n = 0;
long long len = 0;
long long nlen = 0;
+ set<DiskLoc> recs;
while( c->ok() ) {
n++;
+
+ if( n < 1000000 )
+ recs.insert(c->currLoc());
+
+// if( c->currLoc() == DiskLoc(0, 0x476878) ) {
+// cout << "************** target exists in base collection \n";
+// cout << c->current().toString() << endl;
+// }
+
Record *r = c->_current();
len += r->lengthWithHeaders;
nlen += r->netLength();
@@ -373,21 +383,33 @@ string validateNS(const char *ns, NamespaceDetails *d) {
ss << endl;
int ndel = 0;
long long delSize = 0;
+ 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;
}
}
- ss << " deleted: n: " << ndel << " size: " << delSize << endl;
+ ss << " deleted: n: " << ndel << " size: " << delSize << '\n';
+ if( incorrect ) {
+ ss << " corrupt: " << incorrect << " records from datafile are in deleted list\n";
+ valid = false;
+ }
int idxn = 0;
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;
}
@@ -399,6 +421,7 @@ string validateNS(const char *ns, NamespaceDetails *d) {
}
catch(AssertionException) {
ss << "\n exception during validate\n" << endl;
+ valid = false;
}
if( !valid )