summaryrefslogtreecommitdiff
path: root/db/repl/rs_sync.cpp
diff options
context:
space:
mode:
authorKristina <kristina@10gen.com>2011-11-14 13:10:52 -0500
committerKristina <kristina@10gen.com>2011-11-14 13:10:52 -0500
commit94b35f403221390f5dac1750a5c4b6302eaadf2b (patch)
tree6a42f61f65ab0a3004f5e2562d19059d357d4e4b /db/repl/rs_sync.cpp
parent1519ef321f72b59dc8b586f049e7238728727e91 (diff)
downloadmongo-94b35f403221390f5dac1750a5c4b6302eaadf2b.tar.gz
Generalize recloning docs on initial oplog application SERVER-4270
Conflicts: db/repl.cpp db/repl.h db/repl/rs_sync.cpp
Diffstat (limited to 'db/repl/rs_sync.cpp')
-rw-r--r--db/repl/rs_sync.cpp41
1 files changed, 2 insertions, 39 deletions
diff --git a/db/repl/rs_sync.cpp b/db/repl/rs_sync.cpp
index 7f8522de44b..82c845e7145 100644
--- a/db/repl/rs_sync.cpp
+++ b/db/repl/rs_sync.cpp
@@ -58,7 +58,6 @@ namespace mongo {
const string hn = source->h().toString();
OplogReader r;
- OplogReader missingObjReader;
try {
if( !r.connect(hn) ) {
log() << "replSet initial sync error can't connect to " << hn << " to read " << rsoplog << rsLog;
@@ -137,44 +136,8 @@ namespace mongo {
if( ts >= applyGTE ) { // optimes before we started copying need not be applied.
bool failedUpdate = syncApply(o);
- if( failedUpdate ) {
- // we don't have the object yet, which is possible on initial sync. get it.
- log() << "replSet info adding missing object" << endl; // rare enough we can log
- if( !missingObjReader.connect(hn) ) { // ok to call more than once
- log() << "replSet initial sync fails, couldn't connect to " << hn << endl;
- return false;
- }
- const char *ns = o.getStringField("ns");
- BSONObj query = BSONObjBuilder().append(o.getObjectField("o2")["_id"]).obj(); // might be more than just _id in the update criteria
- BSONObj missingObj;
- try {
- missingObj = missingObjReader.findOne(
- ns,
- query );
- } catch(...) {
- log() << "replSet assertion fetching missing object" << endl;
- throw;
- }
- if( missingObj.isEmpty() ) {
- log() << "replSet missing object not found on source. presumably deleted later in oplog" << endl;
- log() << "replSet op: " << o.toString() << endl;
- }
- else {
- Client::Context ctx(ns);
- try {
- DiskLoc d = theDataFileMgr.insert(ns, (void*) missingObj.objdata(), missingObj.objsize());
- assert( !d.isNull() );
- } catch(...) {
- log() << "replSet assertion during insert of missing object" << endl;
- throw;
- }
- // now reapply the update from above
- bool failed = syncApply(o);
- if( failed ) {
- log() << "replSet update still fails after adding missing object " << ns << endl;
- assert(false);
- }
- }
+ if( failedUpdate && shouldRetry(o, hn)) {
+ uassert(15915, "replSet update still fails after adding missing object", syncApply(o));
}
}
_logOpObjRS(o); /* with repl sets we write the ops to our oplog too */