File tree Expand file tree Collapse file tree 4 files changed +17
-34
lines changed Expand file tree Collapse file tree 4 files changed +17
-34
lines changed Original file line number Diff line number Diff line change @@ -851,7 +851,7 @@ namespace mongo {
851851 return ;
852852 cc ().getAuthenticationInfo ()->authorize (" local" ," _repl" );
853853 }
854-
854+
855855 void ReplSetImpl::setMinValid (BSONObj obj) {
856856 BSONObjBuilder builder;
857857 builder.appendTimestamp (" ts" , obj[" ts" ].date ());
@@ -860,13 +860,5 @@ namespace mongo {
860860 Helpers::putSingleton (" local.replset.minvalid" , builder.obj ());
861861 }
862862
863- OpTime ReplSetImpl::getMinValid () {
864- Lock::DBRead lk (" local.replset.minvalid" );
865- BSONObj mv;
866- if (Helpers::getSingleton (" local.replset.minvalid" , mv)) {
867- return mv[" ts" ]._opTime ();
868- }
869- return OpTime ();
870- }
871863}
872864
Original file line number Diff line number Diff line change @@ -539,17 +539,8 @@ namespace mongo {
539539 void syncRollback (OplogReader& r);
540540 void syncThread ();
541541 const OpTime lastOtherOpTime () const ;
542-
543- /* *
544- * When a member reaches its minValid optime it is in a consistent state. Thus, minValid is
545- * set as the last step in initial sync (if no minValid is set, this indicates that initial
546- * sync is necessary). It is also used during "normal" sync: the last op in each batch is
547- * used to set minValid, to indicate that we are in a consistent state when the batch has
548- * been fully applied.
549- */
550542 static void setMinValid (BSONObj obj);
551- static OpTime getMinValid ();
552-
543+
553544 int oplogVersion;
554545 private:
555546 IndexPrefetchConfig _indexPrefetchConfig;
Original file line number Diff line number Diff line change @@ -247,12 +247,6 @@ namespace mongo {
247247 result.append (" info" , " Config now saved locally. Should come online in about a minute." );
248248 ReplSet::startupStatus = ReplSet::SOON;
249249 ReplSet::startupStatusMsg.set (" Received replSetInitiate - should come online shortly." );
250-
251- // Dummy minvalid - just something non-null so we can be "up"
252- OpTime minvalid (1 , 0 );
253- BSONObjBuilder bob;
254- bob.appendTimestamp (" ts" , minvalid.asDate ());
255- ReplSet::setMinValid (bob.done ());
256250 }
257251 catch ( DBException& e ) {
258252 log () << " replSet replSetInitiate exception: " << e.what () << rsLog;
Original file line number Diff line number Diff line change @@ -565,15 +565,21 @@ namespace replset {
565565 }
566566 }
567567
568- minvalid = getMinValid ();
569- if ( minvalid <= lastOpTimeWritten ) {
570- golive=true ;
571- }
572- else {
573- sethbmsg (str::stream () << " still syncing, not yet to minValid optime " <<
574- minvalid.toString ());
568+ {
569+ Lock::DBRead lk (" local.replset.minvalid" );
570+ BSONObj mv;
571+ if ( Helpers::getSingleton (" local.replset.minvalid" , mv) ) {
572+ minvalid = mv[" ts" ]._opTime ();
573+ if ( minvalid <= lastOpTimeWritten ) {
574+ golive=true ;
575+ }
576+ else {
577+ sethbmsg (str::stream () << " still syncing, not yet to minValid optime " << minvalid.toString ());
578+ }
579+ }
580+ else
581+ golive = true ; /* must have been the original member */
575582 }
576-
577583 if ( golive ) {
578584 sethbmsg (" " );
579585 changeState (MemberState::RS_SECONDARY);
@@ -668,7 +674,7 @@ namespace replset {
668674 }
669675
670676 /* do we have anything at all? */
671- if ( getMinValid (). isNull () || lastOpTimeWritten.isNull ()) {
677+ if ( lastOpTimeWritten.isNull () ) {
672678 syncDoInitialSync ();
673679 return ; // _syncThread will be recalled, starts from top again in case sync failed.
674680 }
You can’t perform that action at this time.
0 commit comments