summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwight <dmerriman@gmail.com>2008-06-06 09:38:22 -0400
committerDwight <dmerriman@gmail.com>2008-06-06 09:38:22 -0400
commit877b72efcdd55f9fc9b271c707d4b489e551793d (patch)
treeac0ed3a446b606f89ba0c64d695f3dd3f86418d4
parented259a42e88befe6da414d95736e6562c615a32a (diff)
downloadmongo-877b72efcdd55f9fc9b271c707d4b489e551793d.tar.gz
mysterious disappearing blog post fix
-rw-r--r--db/btree.cpp59
-rw-r--r--db/btree.h18
-rw-r--r--db/namespace.h6
-rw-r--r--db/pdfile.cpp95
-rw-r--r--db/pdfile.h6
-rw-r--r--stdafx.h6
-rw-r--r--util/util.cpp1
7 files changed, 135 insertions, 56 deletions
diff --git a/db/btree.cpp b/db/btree.cpp
index 7adeb7987ce..8e2b982d079 100644
--- a/db/btree.cpp
+++ b/db/btree.cpp
@@ -307,7 +307,7 @@ bool BtreeBucket::find(JSObj& key, DiskLoc recordLoc, int& pos) {
return false;
}
-void BtreeBucket::delBucket(const DiskLoc& thisLoc, const char *ns) {
+void BtreeBucket::delBucket(const DiskLoc& thisLoc, IndexDetails& id) {
assert( !isHead() );
BtreeBucket *p = parent.btree();
@@ -332,11 +332,11 @@ found:
//defensive:
n = -1;
parent.Null();
- theDataFileMgr.deleteRecord(ns, thisLoc.rec(), thisLoc);
+ theDataFileMgr.deleteRecord(id.indexNamespace().c_str(), thisLoc.rec(), thisLoc);
}
/* note: may delete the entire bucket! this invalid upon return sometimes. */
-void BtreeBucket::delKeyAtPos(const DiskLoc& thisLoc, const char *ns, int p) {
+void BtreeBucket::delKeyAtPos(const DiskLoc& thisLoc, IndexDetails& id, int p) {
assert(n>0);
DiskLoc left = childForPos(p);
@@ -345,7 +345,7 @@ void BtreeBucket::delKeyAtPos(const DiskLoc& thisLoc, const char *ns, int p) {
if( isHead() )
_delKeyAtPos(p); // we don't delete the top bucket ever
else
- delBucket(thisLoc, ns);
+ delBucket(thisLoc, id);
return;
}
markUnused(p);
@@ -361,9 +361,9 @@ void BtreeBucket::delKeyAtPos(const DiskLoc& thisLoc, const char *ns, int p) {
int verbose = 0;
int qqq = 0;
-bool BtreeBucket::unindex(const DiskLoc& thisLoc, const char *ns, JSObj& key, const DiskLoc& recordLoc ) {
+bool BtreeBucket::unindex(const DiskLoc& thisLoc, IndexDetails& id, JSObj& key, const DiskLoc& recordLoc ) {
if( key.objsize() > KeyMax ) {
- problem() << "unindex: key too large to index, skipping " << ns << ' ' << key.toString() << endl;
+ problem() << "unindex: key too large to index, skipping " << id.indexNamespace() << ' ' << key.toString() << endl;
return false;
}
@@ -371,7 +371,7 @@ bool BtreeBucket::unindex(const DiskLoc& thisLoc, const char *ns, JSObj& key, co
bool found;
DiskLoc loc = locate(thisLoc, key, pos, found, recordLoc, 1);
if( found ) {
- loc.btree()->delKeyAtPos(loc, ns, pos);
+ loc.btree()->delKeyAtPos(loc, id, pos);
return true;
}
return false;
@@ -400,7 +400,7 @@ void BtreeBucket::fixParentPtrs(const DiskLoc& thisLoc) {
/* keypos - where to insert the key i3n range 0..n. 0=make leftmost, n=make rightmost.
*/
-void BtreeBucket::insertHere(DiskLoc thisLoc, const char *ns, int keypos,
+void BtreeBucket::insertHere(DiskLoc thisLoc, int keypos,
DiskLoc recordLoc, JSObj& key,
DiskLoc lchild, DiskLoc rchild, IndexDetails& idx)
{
@@ -415,7 +415,7 @@ void BtreeBucket::insertHere(DiskLoc thisLoc, const char *ns, int keypos,
if( keypos+1 == n ) { // last key
if( nextChild != lchild ) {
cout << "ERROR nextChild != lchild" << endl;
- cout << " thisLoc: " << thisLoc.toString() << ' ' << ns << endl;
+ cout << " thisLoc: " << thisLoc.toString() << ' ' << idx.indexNamespace() << endl;
cout << " keyPos: " << keypos << " n:" << n << endl;
cout << " nextChild: " << nextChild.toString() << " lchild: " << lchild.toString() << endl;
cout << " recordLoc: " << recordLoc.toString() << " rchild: " << rchild.toString() << endl;
@@ -439,7 +439,7 @@ void BtreeBucket::insertHere(DiskLoc thisLoc, const char *ns, int keypos,
k(keypos).prevChildBucket = lchild;
if( k(keypos+1).prevChildBucket != lchild ) {
cout << "ERROR k(keypos+1).prevChildBucket != lchild" << endl;
- cout << " thisLoc: " << thisLoc.toString() << ' ' << ns << endl;
+ cout << " thisLoc: " << thisLoc.toString() << ' ' << idx.indexNamespace() << endl;
cout << " keyPos: " << keypos << " n:" << n << endl;
cout << " k(keypos+1).pcb: " << k(keypos+1).prevChildBucket.toString() << " lchild: " << lchild.toString() << endl;
cout << " recordLoc: " << recordLoc.toString() << " rchild: " << rchild.toString() << endl;
@@ -478,7 +478,7 @@ void BtreeBucket::insertHere(DiskLoc thisLoc, const char *ns, int keypos,
if( mid < 3 ) {
problem() << "Assertion failure - mid<3: duplicate key bug not fixed yet" << endl;
cout << "Assertion failure - mid<3: duplicate key bug not fixed yet" << endl;
- cout << " ns:" << ns << endl;
+ cout << " ns:" << idx.indexNamespace() << endl;
cout << " key:" << mn.key.toString() << endl;
break;
}
@@ -503,7 +503,7 @@ void BtreeBucket::insertHere(DiskLoc thisLoc, const char *ns, int keypos,
r->nextChild = nextChild;
r->assertValid();
//r->dump();
- rLoc = theDataFileMgr.insert(ns, r, r->Size, true);
+ rLoc = theDataFileMgr.insert(idx.indexNamespace().c_str(), r, r->Size, true);
if( split_debug )
cout << " new rLoc:" << rLoc.toString() << endl;
free(r); r = 0;
@@ -524,7 +524,7 @@ void BtreeBucket::insertHere(DiskLoc thisLoc, const char *ns, int keypos,
p->pushBack(middle.recordLoc, middle.key, thisLoc);
p->nextChild = rLoc;
p->assertValid();
- parent = idx.head = theDataFileMgr.insert(ns, p, p->Size, true);
+ parent = idx.head = theDataFileMgr.insert(idx.indexNamespace().c_str(), p, p->Size, true);
if( split_debug )
cout << " we were root, making new root:" << hex << parent.getOfs() << dec << endl;
free(p);
@@ -537,7 +537,7 @@ void BtreeBucket::insertHere(DiskLoc thisLoc, const char *ns, int keypos,
rLoc.btree()->parent = parent;
if( split_debug )
cout << " promoting middle key " << middle.key.toString() << endl;
- parent.btree()->_insert(parent, ns, middle.recordLoc, middle.key, false, thisLoc, rLoc, idx);
+ parent.btree()->_insert(parent, middle.recordLoc, middle.key, false, thisLoc, rLoc, idx);
}
BtreeBucket *br = rLoc.btree();
//br->dump();
@@ -560,16 +560,15 @@ void BtreeBucket::insertHere(DiskLoc thisLoc, const char *ns, int keypos,
// if( keypos < mid ) {
if( split_debug )
cout << " keypos<mid, insertHere() the new key" << endl;
- insertHere(thisLoc, ns, keypos, recordLoc, key, lchild, rchild, idx);
+ insertHere(thisLoc, keypos, recordLoc, key, lchild, rchild, idx);
//dump();
} else if( highest ) {
// else handled above already.
int kp = keypos-mid-1; assert(kp>=0);
- rLoc.btree()->insertHere(rLoc, ns, kp, recordLoc, key, lchild, rchild, idx);
+ rLoc.btree()->insertHere(rLoc, kp, recordLoc, key, lchild, rchild, idx);
// set a bp here.
// if( !lchild.isNull() ) cout << lchild.btree()->parent.toString() << endl;
// if( !rchild.isNull() ) cout << rchild.btree()->parent.toString() << endl;
-// cout << "temp" << endl;
}
}
@@ -577,9 +576,9 @@ void BtreeBucket::insertHere(DiskLoc thisLoc, const char *ns, int keypos,
cout << " split end " << hex << thisLoc.getOfs() << dec << endl;
}
-DiskLoc BtreeBucket::addHead(const char *ns) {
+DiskLoc BtreeBucket::addHead(IndexDetails& id) {
BtreeBucket *p = allocTemp();
- DiskLoc loc = theDataFileMgr.insert(ns, p, p->Size, true);
+ DiskLoc loc = theDataFileMgr.insert(id.indexNamespace().c_str(), p, p->Size, true);
return loc;
}
@@ -665,11 +664,11 @@ DiskLoc BtreeBucket::locate(const DiskLoc& thisLoc, JSObj& key, int& pos, bool&
}
/* thisloc is the location of this bucket object. you must pass that in. */
-int BtreeBucket::_insert(DiskLoc thisLoc, const char *ns, DiskLoc recordLoc,
+int BtreeBucket::_insert(DiskLoc thisLoc, DiskLoc recordLoc,
JSObj& key, bool dupsAllowed,
DiskLoc lChild, DiskLoc rChild, IndexDetails& idx) {
if( key.objsize() > KeyMax ) {
- problem() << "ERROR: key too large len:" << key.objsize() << " max:" << KeyMax << ' ' << ns << endl;
+ problem() << "ERROR: key too large len:" << key.objsize() << " max:" << KeyMax << ' ' << idx.indexNamespace() << endl;
return 2;
}
assert( key.objsize() > 0 );
@@ -690,7 +689,7 @@ int BtreeBucket::_insert(DiskLoc thisLoc, const char *ns, DiskLoc recordLoc,
}
cout << "_insert(): key already exists in index\n";
- cout << " " << ns << " thisLoc:" << thisLoc.toString() << '\n';
+ cout << " " << idx.indexNamespace().c_str() << " thisLoc:" << thisLoc.toString() << '\n';
cout << " " << key.toString() << '\n';
cout << " " << "recordLoc:" << recordLoc.toString() << " pos:" << pos << endl;
cout << " old l r: " << childForPos(pos).toString() << ' ' << childForPos(pos+1).toString() << endl;
@@ -710,16 +709,16 @@ int BtreeBucket::_insert(DiskLoc thisLoc, const char *ns, DiskLoc recordLoc,
*/
}
-// cout << "TEMP: key: " << key.toString() << endl;
+ DEBUGGING cout << "TEMP: key: " << key.toString() << endl;
DiskLoc& child = getChild(pos);
if( insert_debug )
cout << " getChild(" << pos << "): " << child.toString() << endl;
if( child.isNull() || !rChild.isNull() /* means an 'internal' insert */ ) {
- insertHere(thisLoc, ns, pos, recordLoc, key, lChild, rChild, idx);
+ insertHere(thisLoc, pos, recordLoc, key, lChild, rChild, idx);
return 0;
}
- return child.btree()->insert(child, ns, recordLoc, key, dupsAllowed, idx, false);
+ return child.btree()->insert(child, recordLoc, key, dupsAllowed, idx, false);
}
void BtreeBucket::dump() {
@@ -757,27 +756,29 @@ void tempMusic(DiskLoc thisLoc)
}
/* todo: meaning of return code unclear clean up */
-int BtreeBucket::insert(DiskLoc thisLoc, const char *ns, DiskLoc recordLoc,
+int BtreeBucket::insert(DiskLoc thisLoc, DiskLoc recordLoc,
JSObj& key, bool dupsAllowed, IndexDetails& idx, bool toplevel)
{
if( toplevel ) {
if( key.objsize() > KeyMax ) {
- problem() << "Btree::insert: key too large to index, skipping " << ns << ' ' << key.toString() << '\n';
+ problem() << "Btree::insert: key too large to index, skipping " << idx.indexNamespace().c_str() << ' ' << key.toString() << '\n';
return 3;
}
++ninserts;
- if( /*ninserts > 127250 || */ninserts % 1000 == 0 ) {
+ /*
+ if( ninserts % 1000 == 0 ) {
cout << "ninserts: " << ninserts << endl;
if( 0 && ninserts >= 127287 ) {
cout << "debug?" << endl;
split_debug = 1;
}
}
+ */
}
bool chk = false;
- int x = _insert(thisLoc, ns, recordLoc, key, dupsAllowed, DiskLoc(), DiskLoc(), idx);
+ int x = _insert(thisLoc, recordLoc, key, dupsAllowed, DiskLoc(), DiskLoc(), idx);
assertValid();
/* if( toplevel ) {
diff --git a/db/btree.h b/db/btree.h
index a2b7c43cf9d..407a954ca27 100644
--- a/db/btree.h
+++ b/db/btree.h
@@ -114,12 +114,12 @@ class BtreeBucket : public BucketBasics {
friend class BtreeCursor;
public:
void dump();
- /* rc: 0 = ok */
- static DiskLoc addHead(const char *ns); /* start a new index off, empty */
- int insert(DiskLoc thisLoc, const char *ns, DiskLoc recordLoc,
+
+ static DiskLoc addHead(IndexDetails&); /* start a new index off, empty */
+ int insert(DiskLoc thisLoc, DiskLoc recordLoc,
JSObj& key, bool dupsAllowed, IndexDetails& idx, bool toplevel);
-// void update(const DiskLoc& recordLoc, JSObj& key);
- bool unindex(const DiskLoc& thisLoc, const char *ns, JSObj& key, const DiskLoc& recordLoc);
+
+ bool unindex(const DiskLoc& thisLoc, IndexDetails& id, JSObj& key, const DiskLoc& recordLoc);
/* locate may return an "unused" key that is just a marker. so be careful.
looks for a key:recordloc pair.
@@ -134,14 +134,14 @@ public:
void shape(stringstream&);
private:
void fixParentPtrs(const DiskLoc& thisLoc);
- void delBucket(const DiskLoc& thisLoc, const char *ns);
- void delKeyAtPos(const DiskLoc& thisLoc, const char *ns, int p);
+ void delBucket(const DiskLoc& thisLoc, IndexDetails&);
+ void delKeyAtPos(const DiskLoc& thisLoc, IndexDetails& id, int p);
JSObj keyAt(int keyOfs) { return keyOfs >= n ? JSObj() : keyNode(keyOfs).key; }
static BtreeBucket* allocTemp(); /* caller must release with free() */
- void insertHere(DiskLoc thisLoc, const char *ns, int keypos,
+ void insertHere(DiskLoc thisLoc, int keypos,
DiskLoc recordLoc, JSObj& key,
DiskLoc lchild, DiskLoc rchild, IndexDetails&);
- int _insert(DiskLoc thisLoc, const char *ns, DiskLoc recordLoc,
+ int _insert(DiskLoc thisLoc, DiskLoc recordLoc,
JSObj& key, bool dupsAllowed,
DiskLoc lChild, DiskLoc rChild, IndexDetails&);
bool find(JSObj& key, DiskLoc recordLoc, int& pos);
diff --git a/db/namespace.h b/db/namespace.h
index 9107971b391..ed9613d58f4 100644
--- a/db/namespace.h
+++ b/db/namespace.h
@@ -45,7 +45,10 @@ const int MaxIndexes = 10;
class IndexDetails {
public:
DiskLoc head; /* btree head */
- DiskLoc info; /* index info object. { name:, ns:, key: } */
+ /* index info object.
+ { name:"nameofindex", ns:"parentnsname", key: {keypattobject} }
+ */
+ DiskLoc info;
/* pull out the relevant key objects from obj, so we
can index them. Note that the set is multiple elements
@@ -111,6 +114,7 @@ public:
DiskLoc alloc(const char *ns, int lenToAlloc, DiskLoc& extentLoc);
void addDeletedRec(DeletedRecord *d, DiskLoc dloc);
+ void dumpDeleted(set<DiskLoc> *extents = 0);
private:
DiskLoc __stdAlloc(int len);
DiskLoc _alloc(const char *ns, int len);
diff --git a/db/pdfile.cpp b/db/pdfile.cpp
index 2d6b872046e..c063d91b1c1 100644
--- a/db/pdfile.cpp
+++ b/db/pdfile.cpp
@@ -68,6 +68,7 @@ int bucketSizes[] = {
//NamespaceIndexMgr namespaceIndexMgr;
void NamespaceDetails::addDeletedRec(DeletedRecord *d, DiskLoc dloc) {
+ DEBUGGING cout << "TEMP: add deleted rec " << dloc.toString() << ' ' << hex << d->extentOfs << endl;
int b = bucket(d->lengthWithHeaders);
DiskLoc& list = deletedList[b];
DiskLoc oldHead = list;
@@ -90,6 +91,8 @@ DiskLoc NamespaceDetails::alloc(const char *ns, int lenToAlloc, DiskLoc& extentL
int regionlen = r->lengthWithHeaders;
extentLoc.set(loc.a(), r->extentOfs);
+ DEBUGGING cout << "TEMP: alloc() returns " << loc.toString() << ' ' << ns << " lentoalloc:" << lenToAlloc << " ext:" << extentLoc.toString() << endl;
+
int left = regionlen - lenToAlloc;
if( left < 24 || (left < (lenToAlloc >> 3) && capped == 0) ) {
// you get the whole thing.
@@ -104,6 +107,7 @@ DiskLoc NamespaceDetails::alloc(const char *ns, int lenToAlloc, DiskLoc& extentL
newDel->extentOfs = r->extentOfs;
newDel->lengthWithHeaders = left;
newDel->nextDeleted.Null();
+
addDeletedRec(newDel, newDelLoc);
return loc;
@@ -171,6 +175,27 @@ DiskLoc NamespaceDetails::__stdAlloc(int len) {
return bestmatch;
}
+void NamespaceDetails::dumpDeleted(set<DiskLoc> *extents) {
+// cout << "DUMP deleted chains" << endl;
+ for( int i = 0; i < Buckets; i++ ) {
+// cout << " bucket " << i << endl;
+ DiskLoc dl = deletedList[i];
+ while( !dl.isNull() ) {
+ DeletedRecord *r = dl.drec();
+ DiskLoc extLoc(dl.a(), r->extentOfs);
+ if( extents == 0 || extents->count(extLoc) <= 0 ) {
+ cout << " bucket " << i << endl;
+ cout << " " << dl.toString() << " ext:" << extLoc.toString();
+ if( extents && extents->count(extLoc) <= 0 )
+ cout << '?';
+ cout << " len:" << r->lengthWithHeaders << endl;
+ }
+ dl = r->nextDeleted;
+ }
+ }
+// cout << endl;
+}
+
/* combine adjacent deleted records
this is O(n^2) but we call it for capped tables where typically n==1 or 2!
@@ -198,6 +223,7 @@ void NamespaceDetails::compact() {
while( 1 ) {
j++;
if( j == drecs.end() ) {
+ DEBUGGING cout << "TEMP: compact adddelrec\n";
addDeletedRec(a.drec(), a);
break;
}
@@ -207,11 +233,13 @@ void NamespaceDetails::compact() {
a.drec()->lengthWithHeaders += b.drec()->lengthWithHeaders;
j++;
if( j == drecs.end() ) {
+ DEBUGGING cout << "temp: compact adddelrec2\n";
addDeletedRec(a.drec(), a);
return;
}
b = *j;
}
+ DEBUGGING cout << "temp: compact adddelrec3\n";
addDeletedRec(a.drec(), a);
a = b;
}
@@ -405,6 +433,7 @@ Extent* PhysicalDataFile::newExtent(const char *ns, int approxSize, int loops) {
}
details->lastExtentSize = approxSize;
+ DEBUGGING cout << "temp: newextent adddelrec " << ns << endl;
details->addDeletedRec(emptyLoc.drec(), emptyLoc);
cout << "new extent size: 0x" << hex << ExtentSize << " loc: 0x" << hex << offset << dec;
@@ -487,12 +516,33 @@ auto_ptr<Cursor> DataFileMgr::findAll(const char *ns) {
DiskLoc loc;
bool found = nsindex(ns)->find(ns, loc);
if( !found ) {
- cout << "info: findAll() namespace does not exist: " << ns << endl;
+ // cout << "info: findAll() namespace does not exist: " << ns << endl;
return auto_ptr<Cursor>(new BasicCursor(DiskLoc()));
}
+
Extent *e = getExtent(loc);
+
+ DEBUGGING {
+ cout << "temp: listing extents for " << ns << endl;
+ DiskLoc tmp = loc;
+ set<DiskLoc> extents;
+
+ while( 1 ) {
+ Extent *f = getExtent(tmp);
+ cout << "extent: " << tmp.toString() << endl;
+ extents.insert(tmp);
+ tmp = f->xnext;
+ if( tmp.isNull() )
+ break;
+ f = f->getNextExtent();
+ }
+
+ cout << endl;
+ nsdetails(ns)->dumpDeleted(&extents);
+ }
+
while( e->firstRecord.isNull() && !e->xnext.isNull() ) {
- cout << " DFM::findAll(): extent empty, skipping ahead" << endl;
+ OCCASIONALLY cout << "info DFM::findAll(): extent " << loc.toString() << " was empty, skipping ahead" << endl;
// find a nonempty extent
// it might be nice to free the whole extent here! but have to clean up free recs then.
e = e->getNextExtent();
@@ -512,7 +562,7 @@ auto_ptr<Cursor> findTableScan(const char *ns, JSObj& order) {
return auto_ptr<Cursor>(new BasicCursor(DiskLoc()));
Extent *e = d->lastExtent.ext();
while( e->lastRecord.isNull() && !e->xprev.isNull() ) {
- cout << " findTableScan: extent empty, skipping ahead" << endl;
+ OCCASIONALLY cout << " findTableScan: extent empty, skipping ahead" << endl;
e = e->getPrevExtent();
}
return auto_ptr<Cursor>(new ReverseCursor( e->lastRecord ));
@@ -568,11 +618,11 @@ void _unindexRecord(const char *ns, IndexDetails& id, JSObj& obj, const DiskLoc&
nUnindexes++;
bool ok = false;
try {
- ok = id.head.btree()->unindex(id.head, ns, j, dl);
+ ok = id.head.btree()->unindex(id.head, id, j, dl);
}
catch(AssertionException) {
cout << " caught assertion _unindexRecord " << id.indexNamespace() << '\n';
- problem() << "Assertion failure: _unindex failed " << ns << endl;
+ problem() << "Assertion failure: _unindex failed " << id.indexNamespace() << endl;
cout << "Assertion failure: _unindex failed" << '\n';
cout << " obj:" << obj.toString() << '\n';
cout << " key:" << j.toString() << '\n';
@@ -596,6 +646,8 @@ void unindexRecord(const char *ns, NamespaceDetails *d, Record *todelete, const
void DataFileMgr::deleteRecord(const char *ns, Record *todelete, const DiskLoc& dl, bool cappedOK)
{
+ int tempextofs = todelete->extentOfs;
+
NamespaceDetails* d = nsdetails(ns);
if( d->capped && !cappedOK ) {
cout << "failing remove on a capped ns " << ns << endl;
@@ -636,6 +688,17 @@ void DataFileMgr::deleteRecord(const char *ns, Record *todelete, const DiskLoc&
{
d->nrecords--;
d->datasize -= todelete->netLength();
+/// DEBUGGING << "temp: dddelrec deleterecord " << ns << endl;
+// if( todelete->extentOfs == 0xaca500 ) {
+// cout << "break\n";
+// }
+/*
+TEMP: add deleted rec 0:aca5b0 aca500
+temp: adddelrec deleterecord admin.blog.posts
+TEMP: add deleted rec 0:b9e750 b6a500
+temp: adddelrec deleterecord admin.blog.posts
+*/
+
d->addDeletedRec((DeletedRecord*)todelete, dl);
}
}
@@ -697,7 +760,7 @@ void DataFileMgr::update(
string idxns = idx.indexNamespace();
for( unsigned i = 0; i < removed.size(); i++ ) {
try {
- idx.head.btree()->unindex(idx.head, idxns.c_str(), *removed[i], dl);
+ idx.head.btree()->unindex(idx.head, idx, *removed[i], dl);
}
catch(AssertionException) {
ss << " exception update unindex ";
@@ -711,7 +774,7 @@ void DataFileMgr::update(
for( unsigned i = 0; i < added.size(); i++ ) {
try {
idx.head.btree()->insert(
- idx.head, idxns.c_str(),
+ idx.head,
dl, *added[i], false, idx, true);
}
catch(AssertionException) {
@@ -750,8 +813,8 @@ void _indexRecord(IndexDetails& idx, JSObj& obj, DiskLoc newRecordLoc) {
for( set<JSObj>::iterator i=keys.begin(); i != keys.end(); i++ ) {
assert( !newRecordLoc.isNull() );
try {
-// cout << "TEMP index: " << newRecordLoc.toString() << obj.toString() << endl;
- idx.head.btree()->insert(idx.head, idx.indexNamespace().c_str(), newRecordLoc,
+// DEBUGGING << "temp index: " << newRecordLoc.toString() << obj.toString() << endl;
+ idx.head.btree()->insert(idx.head, newRecordLoc,
(JSObj&) *i, false, idx, true);
}
catch(AssertionException) {
@@ -810,7 +873,7 @@ DiskLoc DataFileMgr::insert(const char *ns, const void *buf, int len, bool god)
}
NamespaceDetails *tableToIndex = 0;
- string indexFullNS;
+
const char *tabletoidxns = 0;
if( addIndex ) {
JSObj io((const char *) buf);
@@ -824,20 +887,20 @@ DiskLoc DataFileMgr::insert(const char *ns, const void *buf, int len, bool god)
}
tableToIndex = nsdetails(tabletoidxns);
if( tableToIndex == 0 ) {
- cout << "ERROR: bad add index attempt, no such table(ns):" << tabletoidxns << endl;
+ cout << "user warning: bad add index attempt, no such table(ns):" << tabletoidxns << endl;
return DiskLoc();
}
if( tableToIndex->nIndexes >= MaxIndexes ) {
- cout << "ERROR: bad add index attempt, too many indexes for:" << tabletoidxns << endl;
+ cout << "user warning: bad add index attempt, too many indexes for:" << tabletoidxns << endl;
return DiskLoc();
}
if( tableToIndex->findIndexByName(name) >= 0 ) {
//cout << "INFO: index:" << name << " already exists for:" << tabletoidxns << endl;
return DiskLoc();
}
- indexFullNS = tabletoidxns;
- indexFullNS += ".$";
- indexFullNS += name; // client.table.$index -- note this doesn't contain jsobjs, it contains BtreeBuckets.
+ //indexFullNS = tabletoidxns;
+ //indexFullNS += ".$";
+ //indexFullNS += name; // client.table.$index -- note this doesn't contain jsobjs, it contains BtreeBuckets.
}
DiskLoc extentLoc;
@@ -879,7 +942,7 @@ DiskLoc DataFileMgr::insert(const char *ns, const void *buf, int len, bool god)
if( tableToIndex ) {
IndexDetails& idxinfo = tableToIndex->indexes[tableToIndex->nIndexes];
idxinfo.info = loc;
- idxinfo.head = BtreeBucket::addHead(indexFullNS.c_str());
+ idxinfo.head = BtreeBucket::addHead(idxinfo);
tableToIndex->nIndexes++;
/* todo: index existing records here */
addExistingToIndex(tabletoidxns, idxinfo);
diff --git a/db/pdfile.h b/db/pdfile.h
index 7ef25a3e0a1..bb94089d917 100644
--- a/db/pdfile.h
+++ b/db/pdfile.h
@@ -253,7 +253,11 @@ public:
assert( ok() );
return curr.rec();
}
- JSObj current() { return JSObj( _current() ); }
+ JSObj current() {
+ Record *r = _current();
+ JSObj j(r);
+ return j;
+ }
virtual DiskLoc currLoc() { return curr; }
bool advance() {
diff --git a/stdafx.h b/stdafx.h
index b63114fd161..2c27004912a 100644
--- a/stdafx.h
+++ b/stdafx.h
@@ -103,3 +103,9 @@ inline ofstream& problem() {
problems << curNs << ' ';
return problems;
}
+
+#define DEBUGGING if( 0 )
+
+extern unsigned occasion;
+
+#define OCCASIONALLY if( ++occasion % 16 == 0 )
diff --git a/util/util.cpp b/util/util.cpp
index eef48c8e750..612a27f589c 100644
--- a/util/util.cpp
+++ b/util/util.cpp
@@ -1,6 +1,7 @@
#include "stdafx.h"
#include "goodies.h"
+unsigned occasion = 0;
bool goingAway = false;
bool isPrime(int n) {