From 8d5f5b6002325c0d6ac537ffd28d39ce93a24441 Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Thu, 1 Jul 2010 14:35:34 -0400 Subject: pretouch experiment --- db/db.cpp | 6 ++++++ db/repl.cpp | 33 +++++++++++++++++++++++++++++++++ db/repl.h | 4 +++- 3 files changed, 42 insertions(+), 1 deletion(-) 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(), "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(), "size limit (in MB) for op log") ("opIdMem", po::value(), "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().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: , ns: ..., o: , o2: , b: } @@ -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) { } }; -- cgit v1.2.1