diff options
author | Eliot Horowitz <eliot@10gen.com> | 2010-07-01 14:35:34 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2010-07-01 14:35:34 -0400 |
commit | 8d5f5b6002325c0d6ac537ffd28d39ce93a24441 (patch) | |
tree | 375d91b7aff65c854b04ba2c0e4a33c0dee235c4 | |
parent | eb9efb78c7e94de6a6b0d3f6b131335e10922bc4 (diff) | |
download | mongo-8d5f5b6002325c0d6ac537ffd28d39ce93a24441.tar.gz |
pretouch experiment
-rw-r--r-- | db/db.cpp | 6 | ||||
-rw-r--r-- | db/repl.cpp | 33 | ||||
-rw-r--r-- | db/repl.h | 4 |
3 files changed, 42 insertions, 1 deletions
diff --git a/db/db.cpp b/db/db.cpp index 9be403129a3..b92d8124a42 100644 --- a/db/db.cpp +++ b/db/db.cpp @@ -661,6 +661,7 @@ int main(int argc, char* argv[], char *envp[] ) ("slavedelay", po::value<int>(), "specify delay (in seconds) to be used when applying master ops to slave") ("fastsync", "indicate that this instance is starting from a dbpath snapshot of the repl peer") ("autoresync", "automatically resync if slave data is stale") + ("pretouch", "turn on pretouch experiment TESTING ONLY") ("oplogSize", po::value<int>(), "size limit (in MB) for op log") ("opIdMem", po::value<long>(), "size limit (in bytes) for in memory storage of op ids") ; @@ -832,6 +833,11 @@ int main(int argc, char* argv[], char *envp[] ) if (params.count("autoresync")) { replSettings.autoresync = true; } + + if (params.count("pretouch")) { + replSettings.pretouch = true; + } + if (params.count("source")) { /* specifies what the source in local.sources should be */ cmdLine.source = params["source"].as<string>().c_str(); diff --git a/db/repl.cpp b/db/repl.cpp index 0d12b924fa2..2283446a175 100644 --- a/db/repl.cpp +++ b/db/repl.cpp @@ -895,6 +895,36 @@ namespace mongo { log() << "sync: caught db exception " << e << " while applying op: " << op << endl;; } } + + void pretouchOperation(const BSONObj& op) { + const char *which = "o"; + const char *opType = op.getStringField("op"); + if ( *opType == 'i' ) + ; + else if( *opType == 'u' ) + which = "o2"; + else + return; + /* todo : other operations */ + + try { + BSONObj o = op.getObjectField(which); + BSONElement _id; + if( o.getObjectID(_id) ) { + const char *ns = op.getStringField("ns"); + BSONObjBuilder b; + b.append(_id); + BSONObj result; + readlock lk(ns); + Client::Context ctx( ns ); + Helpers::findById(cc(), ns, b.done(), result); + } + } + catch( DBException& ) { + log() << "ignoring assertion in pretouchOperation()" << endl; + } + } + /* local.$oplog.main is of the form: { ts: ..., op: <optype>, ns: ..., o: <obj> , o2: <extraobj>, b: <boolflag> } @@ -924,6 +954,9 @@ namespace mongo { if ( !only.empty() && only != clientName ) return; + if ( replSettings.pretouch ) + pretouchOperation(op); + dblock lk; if ( localLogTail && replPair && replPair->state == ReplPair::State_Master ) { diff --git a/db/repl.h b/db/repl.h index 9dd9f72faac..3f6909f83cf 100644 --- a/db/repl.h +++ b/db/repl.h @@ -64,9 +64,11 @@ namespace mongo { bool autoresync; int slavedelay; + + bool pretouch; ReplSettings() - : slave(NotSlave) , master(false) , opIdMem(100000000) , fastsync() , autoresync(false), slavedelay() { + : slave(NotSlave) , master(false) , opIdMem(100000000) , fastsync() , autoresync(false), slavedelay(), pretouch(false) { } }; |