diff options
author | Dwight <dmerriman@gmail.com> | 2008-05-01 10:22:05 -0400 |
---|---|---|
committer | Dwight <dmerriman@gmail.com> | 2008-05-01 10:22:05 -0400 |
commit | 548adc2678223e2f5f31f9819ebd3e1111026395 (patch) | |
tree | a09bde562de992e72031400ab6b395d16428b214 | |
parent | def9b1ba010e14929da493fe55d0bce586023e46 (diff) | |
download | mongo-548adc2678223e2f5f31f9819ebd3e1111026395.tar.gz |
don't assert if key to index too big ; nicer msg too
-rw-r--r-- | db/btree.cpp | 19 | ||||
-rw-r--r-- | db/db.cpp | 9 | ||||
-rw-r--r-- | db/pdfile.cpp | 7 |
3 files changed, 25 insertions, 10 deletions
diff --git a/db/btree.cpp b/db/btree.cpp index 7b3d4b4d1e2..7adeb7987ce 100644 --- a/db/btree.cpp +++ b/db/btree.cpp @@ -6,7 +6,7 @@ /* it is easy to do custom sizes for a namespace - all the same for now */
const int BucketSize = 8192;
-const int KeyMax = BucketSize / 8;
+const int KeyMax = BucketSize / 10;
int ninserts = 0;
extern int otherTraceLevel;
@@ -361,7 +361,12 @@ 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, const char *ns, JSObj& key, const DiskLoc& recordLoc ) {
+ if( key.objsize() > KeyMax ) {
+ problem() << "unindex: key too large to index, skipping " << ns << ' ' << key.toString() << endl;
+ return false;
+ }
+
int pos;
bool found;
DiskLoc loc = locate(thisLoc, key, pos, found, recordLoc, 1);
@@ -664,9 +669,9 @@ int BtreeBucket::_insert(DiskLoc thisLoc, const char *ns, DiskLoc recordLoc, JSObj& key, bool dupsAllowed,
DiskLoc lChild, DiskLoc rChild, IndexDetails& idx) {
if( key.objsize() > KeyMax ) {
- cout << "ERROR: key too large len:" << key.objsize() << " max:" << KeyMax << endl;
+ problem() << "ERROR: key too large len:" << key.objsize() << " max:" << KeyMax << ' ' << ns << endl;
return 2;
- }
+ }
assert( key.objsize() > 0 );
int pos;
@@ -751,11 +756,15 @@ void tempMusic(DiskLoc thisLoc) cout << "*** NOT FOUND" << endl;
}
+/* todo: meaning of return code unclear clean up */
int BtreeBucket::insert(DiskLoc thisLoc, const char *ns, DiskLoc recordLoc,
JSObj& key, bool dupsAllowed, IndexDetails& idx, bool toplevel)
{
if( toplevel ) {
- assert( key.objsize() < BucketSize / 10 );
+ if( key.objsize() > KeyMax ) {
+ problem() << "Btree::insert: key too large to index, skipping " << ns << ' ' << key.toString() << '\n';
+ return 3;
+ }
++ninserts;
if( /*ninserts > 127250 || */ninserts % 1000 == 0 ) {
cout << "ninserts: " << ninserts << endl;
diff --git a/db/db.cpp b/db/db.cpp index 0ffcfb54d5d..d588345bf5e 100644 --- a/db/db.cpp +++ b/db/db.cpp @@ -271,7 +271,7 @@ public: };
void listen(int port) {
- const char *Version = "db version: 108 30apr2008 sai hack";
+ const char *Version = "db version: 109 30apr2008 sai hack,keylen";
problem() << Version << endl;
cout << Version << endl;
pdfileInit();
@@ -621,7 +621,12 @@ void initAndListen(int listenPort, const char *dbPath) { dbpath = dbPath;
- pid_t pid = getpid();
+#if !defined(_WIN32)
+ pid_t pid = 0;
+ pid = getpid();
+#else
+ int pid=0;
+#endif
cout << "10Gen DB : starting : pid = " << pid << " port = " << port << " dbpath = " << dbpath << endl;
problem() << "10Gen DB : starting : pid = " << pid << " port = " << port << " dbpath = " << dbpath << endl;
diff --git a/db/pdfile.cpp b/db/pdfile.cpp index 94304ff35f5..f4da75775bf 100644 --- a/db/pdfile.cpp +++ b/db/pdfile.cpp @@ -570,9 +570,6 @@ void _unindexRecord(const char *ns, IndexDetails& id, JSObj& obj, const DiskLoc& }
catch(AssertionException) {
cout << " caught assertion _unindexRecord " << id.indexNamespace() << '\n';
- }
-
- if( !ok ) {
problem() << "Assertion failure: _unindex failed " << ns << endl;
cout << "Assertion failure: _unindex failed" << '\n';
cout << " obj:" << obj.toString() << '\n';
@@ -580,6 +577,10 @@ void _unindexRecord(const char *ns, IndexDetails& id, JSObj& obj, const DiskLoc& cout << " dl:" << dl.toString() << endl;
sayDbContext();
}
+
+ if( !ok ) {
+ cout << "unindex failed (key too big?) " << id.indexNamespace() << '\n';
+ }
}
}
|