diff options
author | Dwight <dmerriman@gmail.com> | 2008-08-26 13:34:34 -0400 |
---|---|---|
committer | Dwight <dmerriman@gmail.com> | 2008-08-26 13:34:34 -0400 |
commit | 43529c43cfc9c95f95501f1797b81bbb7106240e (patch) | |
tree | dcaac2f7d23df95e733396691c0ac6d364e95255 | |
parent | 8d00ee0321bb4b74e9cab129014dbcdfebe5755c (diff) | |
download | mongo-43529c43cfc9c95f95501f1797b81bbb7106240e.tar.gz |
we only clone one database per pass, even if a lot need done. This helps us
avoid overflowing the master's transaction log by doing too much work before going
back to read more transactions. (Imagine a scenario of slave startup where we try to
clone 100 databases in one pass.)
-rw-r--r-- | db/pdfile.cpp | 4 | ||||
-rw-r--r-- | db/query.cpp | 2 | ||||
-rw-r--r-- | db/repl.cpp | 17 | ||||
-rw-r--r-- | db/repl.h | 2 |
4 files changed, 19 insertions, 6 deletions
diff --git a/db/pdfile.cpp b/db/pdfile.cpp index d2fb10b4140..122f54e2b17 100644 --- a/db/pdfile.cpp +++ b/db/pdfile.cpp @@ -402,7 +402,7 @@ int initialExtentSize(int len) { sz = 1000000000; int z = ((int)sz) & 0xffffff00; assert( z > len ); - log() << "initialExtentSize(" << len << ") returns " << z << endl; + DEV log() << "initialExtentSize(" << len << ") returns " << z << endl; return z; } @@ -478,7 +478,7 @@ void PhysicalDataFile::open(int fn, const char *filename) { assert(fn == fileNo); header = (PDFHeader *) mmf.map(filename, length); - assert(header); + uassert("can't map file memory", header); header->init(fileNo, length); } diff --git a/db/query.cpp b/db/query.cpp index 4f99cfa0a85..e4df9643ab5 100644 --- a/db/query.cpp +++ b/db/query.cpp @@ -641,7 +641,7 @@ bool _runCommands(const char *ns, JSObj& jsobj, stringstream& ss, BufBuilder &b, ok = false; } else { dropDatabase(ns); -//finish logOp("c", ns, jsobj); + logOp("c", ns, jsobj); ok = true; } } diff --git a/db/repl.cpp b/db/repl.cpp index 13789376b1f..12722b37377 100644 --- a/db/repl.cpp +++ b/db/repl.cpp @@ -68,7 +68,7 @@ int test2() { /* --------------------------------------------------------------*/ -Source::Source(JSObj o) { +Source::Source(JSObj o) : nClonedThisPass(0) { only = o.getStringField("only"); hostName = o.getStringField("host"); sourceName = o.getStringField("source"); @@ -210,13 +210,23 @@ void Source::applyOperation(JSObj& op) { if( !only.empty() && only != clientName ) return; - dblock lk; + bool newDb = dbs.count(clientName) == 0; + if( newDb && nClonedThisPass ) { + /* we only clone one database per pass, even if a lot need done. This helps us + avoid overflowing the master's transaction log by doing too much work before going + back to read more transactions. (Imagine a scenario of slave startup where we try to + clone 100 databases in one pass.) + */ + return; + } + dblock lk; setClientTempNs(ns); if( client->justCreated || /* datafiles were missing. so we need everything, no matter what sources object says */ - !dbs.count(client->name) ) /* if not in dbs, we've never synced this database before, so we need everything */ + newDb ) /* if not in dbs, we've never synced this database before, so we need everything */ { + nClonedThisPass++; resync(client->name); client->justCreated = false; } @@ -360,6 +370,7 @@ void Source::pullOpLog() { */ bool Source::sync() { log() << "pull: " << sourceName << '@' << hostName << endl; + nClonedThisPass = 0; if( (string("localhost") == hostName || string("127.0.0.1") == hostName) && port == DBPort ) { log() << "pull: can't sync from self (localhost). sources configuration may be wrong." << endl; diff --git a/db/repl.h b/db/repl.h index ee343f547d2..d3708f56860 100644 --- a/db/repl.h +++ b/db/repl.h @@ -106,6 +106,8 @@ public: */ set<string> dbs; + int nClonedThisPass; + static void loadAll(vector<Source*>&); static void cleanup(vector<Source*>&); Source(JSObj); |