Skip to content

Commit 8d5f5b6

Browse files
committed
pretouch experiment
1 parent eb9efb7 commit 8d5f5b6

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

db/db.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ int main(int argc, char* argv[], char *envp[] )
661661
("slavedelay", po::value<int>(), "specify delay (in seconds) to be used when applying master ops to slave")
662662
("fastsync", "indicate that this instance is starting from a dbpath snapshot of the repl peer")
663663
("autoresync", "automatically resync if slave data is stale")
664+
("pretouch", "turn on pretouch experiment TESTING ONLY")
664665
("oplogSize", po::value<int>(), "size limit (in MB) for op log")
665666
("opIdMem", po::value<long>(), "size limit (in bytes) for in memory storage of op ids")
666667
;
@@ -832,6 +833,11 @@ int main(int argc, char* argv[], char *envp[] )
832833
if (params.count("autoresync")) {
833834
replSettings.autoresync = true;
834835
}
836+
837+
if (params.count("pretouch")) {
838+
replSettings.pretouch = true;
839+
}
840+
835841
if (params.count("source")) {
836842
/* specifies what the source in local.sources should be */
837843
cmdLine.source = params["source"].as<string>().c_str();

db/repl.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,36 @@ namespace mongo {
895895
log() << "sync: caught db exception " << e << " while applying op: " << op << endl;;
896896
}
897897
}
898+
899+
void pretouchOperation(const BSONObj& op) {
900+
const char *which = "o";
901+
const char *opType = op.getStringField("op");
902+
if ( *opType == 'i' )
903+
;
904+
else if( *opType == 'u' )
905+
which = "o2";
906+
else
907+
return;
908+
/* todo : other operations */
909+
910+
try {
911+
BSONObj o = op.getObjectField(which);
912+
BSONElement _id;
913+
if( o.getObjectID(_id) ) {
914+
const char *ns = op.getStringField("ns");
915+
BSONObjBuilder b;
916+
b.append(_id);
917+
BSONObj result;
918+
readlock lk(ns);
919+
Client::Context ctx( ns );
920+
Helpers::findById(cc(), ns, b.done(), result);
921+
}
922+
}
923+
catch( DBException& ) {
924+
log() << "ignoring assertion in pretouchOperation()" << endl;
925+
}
926+
}
927+
898928

899929
/* local.$oplog.main is of the form:
900930
{ ts: ..., op: <optype>, ns: ..., o: <obj> , o2: <extraobj>, b: <boolflag> }
@@ -924,6 +954,9 @@ namespace mongo {
924954
if ( !only.empty() && only != clientName )
925955
return;
926956

957+
if ( replSettings.pretouch )
958+
pretouchOperation(op);
959+
927960
dblock lk;
928961

929962
if ( localLogTail && replPair && replPair->state == ReplPair::State_Master ) {

db/repl.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ namespace mongo {
6464
bool autoresync;
6565

6666
int slavedelay;
67+
68+
bool pretouch;
6769

6870
ReplSettings()
69-
: slave(NotSlave) , master(false) , opIdMem(100000000) , fastsync() , autoresync(false), slavedelay() {
71+
: slave(NotSlave) , master(false) , opIdMem(100000000) , fastsync() , autoresync(false), slavedelay(), pretouch(false) {
7072
}
7173

7274
};

0 commit comments

Comments
 (0)