@@ -58,7 +58,6 @@ namespace mongo {
5858
5959 const string hn = source->h ().toString ();
6060 OplogReader r;
61- OplogReader missingObjReader;
6261 try {
6362 if ( !r.connect (hn) ) {
6463 log () << " replSet initial sync error can't connect to " << hn << " to read " << rsoplog << rsLog;
@@ -137,44 +136,8 @@ namespace mongo {
137136
138137 if ( ts >= applyGTE ) { // optimes before we started copying need not be applied.
139138 bool failedUpdate = syncApply (o);
140- if ( failedUpdate ) {
141- // we don't have the object yet, which is possible on initial sync. get it.
142- log () << " replSet info adding missing object" << endl; // rare enough we can log
143- if ( !missingObjReader.connect (hn) ) { // ok to call more than once
144- log () << " replSet initial sync fails, couldn't connect to " << hn << endl;
145- return false ;
146- }
147- const char *ns = o.getStringField (" ns" );
148- BSONObj query = BSONObjBuilder ().append (o.getObjectField (" o2" )[" _id" ]).obj (); // might be more than just _id in the update criteria
149- BSONObj missingObj;
150- try {
151- missingObj = missingObjReader.findOne (
152- ns,
153- query );
154- } catch (...) {
155- log () << " replSet assertion fetching missing object" << endl;
156- throw ;
157- }
158- if ( missingObj.isEmpty () ) {
159- log () << " replSet missing object not found on source. presumably deleted later in oplog" << endl;
160- log () << " replSet op: " << o.toString () << endl;
161- }
162- else {
163- Client::Context ctx (ns);
164- try {
165- DiskLoc d = theDataFileMgr.insert (ns, (void *) missingObj.objdata (), missingObj.objsize ());
166- assert ( !d.isNull () );
167- } catch (...) {
168- log () << " replSet assertion during insert of missing object" << endl;
169- throw ;
170- }
171- // now reapply the update from above
172- bool failed = syncApply (o);
173- if ( failed ) {
174- log () << " replSet update still fails after adding missing object " << ns << endl;
175- assert (false );
176- }
177- }
139+ if ( failedUpdate && shouldRetry (o, hn)) {
140+ uassert (15915 , " replSet update still fails after adding missing object" , syncApply (o));
178141 }
179142 }
180143 _logOpObjRS (o); /* with repl sets we write the ops to our oplog too */
0 commit comments