diff options
author | dwight <dwight@Dwights-MacBook.local> | 2008-08-25 16:53:30 -0400 |
---|---|---|
committer | dwight <dwight@Dwights-MacBook.local> | 2008-08-25 16:53:30 -0400 |
commit | 8d00ee0321bb4b74e9cab129014dbcdfebe5755c (patch) | |
tree | 9fe223ac575ff1170eb54aa73d070e75aaf16b35 | |
parent | 26d42343623aea234c12a46a23204a40eed09747 (diff) | |
parent | ca08e48791b87cfb248ed3cf10c1852d788ae029 (diff) | |
download | mongo-8d00ee0321bb4b74e9cab129014dbcdfebe5755c.tar.gz |
Merge branch 'master' of ssh://git.10gen.com/data/gitroot/p
-rw-r--r-- | db/namespace.h | 6 | ||||
-rw-r--r-- | db/pdfile.cpp | 3 | ||||
-rw-r--r-- | db/repl.cpp | 29 | ||||
-rw-r--r-- | db/repl.h | 1 | ||||
-rw-r--r-- | db/scanandorder.h | 4 | ||||
-rw-r--r-- | stdafx.cpp | 4 | ||||
-rw-r--r-- | stdafx.h | 5 |
7 files changed, 35 insertions, 17 deletions
diff --git a/db/namespace.h b/db/namespace.h index 8229808eed8..ef23cb56c13 100644 --- a/db/namespace.h +++ b/db/namespace.h @@ -273,6 +273,7 @@ extern NamespaceIndexMgr namespaceIndexMgr; */ // "client.a.b.c" -> "client" +const int MaxClientLen = 256; inline void nsToClient(const char *ns, char *client) { const char *p = ns; char *q = client; @@ -285,7 +286,10 @@ inline void nsToClient(const char *ns, char *client) { *q++ = *p++; } *q = 0; - assert(q-client<256); + if(q-client>=MaxClientLen) { + problem() << "nsToClient: ns too long. terminating, buf overrun condition" << endl; + dbexit(60); + } } /* diff --git a/db/pdfile.cpp b/db/pdfile.cpp index 8603faeb29d..d2fb10b4140 100644 --- a/db/pdfile.cpp +++ b/db/pdfile.cpp @@ -47,6 +47,9 @@ int callDepth = 0; extern int otherTraceLevel; +/* this is a good place to set a breakpoint when debugging, as lots of warning things + (assert, wassert) call it. +*/ void sayDbContext(const char *errmsg) { if( errmsg ) { problem() << errmsg << endl; diff --git a/db/repl.cpp b/db/repl.cpp index c5a2caa3a68..13789376b1f 100644 --- a/db/repl.cpp +++ b/db/repl.cpp @@ -69,13 +69,14 @@ int test2() { /* --------------------------------------------------------------*/ Source::Source(JSObj o) { + only = o.getStringField("only"); hostName = o.getStringField("host"); sourceName = o.getStringField("source"); - uassert( !hostName.empty() ); - uassert( !sourceName.empty() ); + uassert( "'host' field not set in sources collection object", !hostName.empty() ); + uassert( "'source' field not set in sources collection object", !sourceName.empty() ); Element e = o.getField("syncedTo"); if( !e.eoo() ) { - uassert( e.type() == Date ); + uassert( "bad sources 'syncedTo' field value", e.type() == Date ); OpTime tmp( e.date() ); syncedTo = tmp; //syncedTo.asDate() = e.date(); @@ -98,6 +99,8 @@ JSObj Source::jsobj() { JSObjBuilder b; b.append("host", hostName); b.append("source", sourceName); + if( !only.empty() ) + b.append("only", only); b.appendDate("syncedTo", syncedTo.asDate()); JSObjBuilder dbs_builder; @@ -198,11 +201,17 @@ bool Source::resync(string db) { } /* { ts: ..., op: <optype>, ns: ..., o: <obj> , o2: <extraobj>, b: <boolflag> } - You must lock dbMutex before calling. */ -void Source::applyOperation(JSObj& op) { - stringstream ss; +void Source::applyOperation(JSObj& op) { + char clientName[MaxClientLen]; const char *ns = op.getStringField("ns"); + nsToClient(ns, clientName); + + if( !only.empty() && only != clientName ) + return; + + dblock lk; + setClientTempNs(ns); if( client->justCreated || /* datafiles were missing. so we need everything, no matter what sources object says */ @@ -212,6 +221,7 @@ void Source::applyOperation(JSObj& op) { client->justCreated = false; } + stringstream ss; const char *opType = op.getStringField("op"); JSObj o = op.getObjectField("o"); if( *opType == 'i' ) { @@ -303,7 +313,6 @@ void Source::pullOpLog() { log() << "pull: initial run\n"; } { - dblock lk; applyOperation(op); n++; } @@ -320,11 +329,11 @@ void Source::pullOpLog() { // apply operations { - dblock lk; while( 1 ) { if( !c->more() ) { log() << "pull: applied " << n << " operations" << endl; syncedTo = t; + dblock lk; save(); // note how far we are synced up to now break; } @@ -337,7 +346,7 @@ void Source::pullOpLog() { t = tmp; if( !( last < t ) ) { problem() << "sync error: last " << last.toString() << " >= t " << t.toString() << endl; - uassert(false); + uassert("bad 'ts' value in sources", false); } applyOperation(op); @@ -489,7 +498,7 @@ void replMain() { int debug_stop_repl = 0; void replSlaveThread() { - sleepsecs(3); + sleepsecs(30); while( 1 ) { try { replMain(); diff --git a/db/repl.h b/db/repl.h index e4c95bfa21e..ee343f547d2 100644 --- a/db/repl.h +++ b/db/repl.h @@ -95,6 +95,7 @@ class Source { public: string hostName; // ip addr or hostname string sourceName; // a logical source name. + string only; // only a certain db. note that in the sources collection, this may not be changed once you start replicating. /* the last time point we have already synced up to. */ OpTime syncedTo; diff --git a/db/scanandorder.h b/db/scanandorder.h index a4489b00b1e..07c38fafe74 100644 --- a/db/scanandorder.h +++ b/db/scanandorder.h @@ -84,7 +84,7 @@ public: JSObj k = order.getKeyFromObject(o); if( (int) best.size() < limit ) { approxSize += k.objsize(); - uassert( approxSize < 1 * 1024 * 1024 ); + uassert( "too much key data for sort() with no index", approxSize < 1 * 1024 * 1024 ); _add(k, o); return; } @@ -111,7 +111,7 @@ public: nFilled++; if( nFilled >= limit ) goto done; - uassert( b.len() < 4000000 ); // appserver limit + uassert( "too much data for sort() with no index", b.len() < 4000000 ); // appserver limit } } done: diff --git a/stdafx.cpp b/stdafx.cpp index f499f8b9bc0..89c5194be32 100644 --- a/stdafx.cpp +++ b/stdafx.cpp @@ -46,8 +46,8 @@ void asserted(const char *msg, const char *file, unsigned line) { throw AssertionException(); } -void uasserted(const char *msg, const char *file, unsigned line) { - problem() << "User Assertion failure " << msg << ' ' << file << ' ' << line << endl; +void uasserted(const char *msg) { + problem() << "User Assertion " << msg << endl; throw AssertionException(); } @@ -58,7 +58,7 @@ public: void asserted(const char *msg, const char *file, unsigned line); void wasserted(const char *msg, const char *file, unsigned line); -void uasserted(const char *msg, const char *file, unsigned line); +void uasserted(const char *msg); void msgasserted(const char *msg); #ifdef assert @@ -68,7 +68,8 @@ void msgasserted(const char *msg); #define assert(_Expression) (void)( (!!(_Expression)) || (asserted(#_Expression, __FILE__, __LINE__), 0) ) /* "user assert". if asserts, user did something wrong, not our code */ -#define uassert(_Expression) (void)( (!!(_Expression)) || (uasserted(#_Expression, __FILE__, __LINE__), 0) ) +//#define uassert(_Expression) (void)( (!!(_Expression)) || (uasserted(#_Expression, __FILE__, __LINE__), 0) ) +#define uassert(msg,_Expression) (void)( (!!(_Expression)) || (uasserted(msg), 0) ) #define xassert(_Expression) (void)( (!!(_Expression)) || (asserted(#_Expression, __FILE__, __LINE__), 0) ) |