示例#1
0
    // call after constructing to start - returns fairly quickly after launching its threads
    void ReplSetImpl::_go() {
        OperationContextImpl txn;

        try {
            loadLastOpTimeWritten(&txn);
        }
        catch (std::exception& e) {
            log() << "replSet error fatal couldn't query the local " << rsoplog
                  << " collection.  Terminating mongod after 30 seconds." << rsLog;
            log() << e.what() << rsLog;
            sleepsecs(30);
            dbexit(EXIT_REPLICATION_ERROR);
            return;
        }

        // initialize _me in SyncSourceFeedback
        bool meEnsured = false;
        while (!inShutdown() && !meEnsured) {
            try {
                syncSourceFeedback.ensureMe(&txn);
                meEnsured = true;
            }
            catch (const DBException& e) {
                warning() << "failed to write to local.me: " << e.what()
                          << " trying again in one second";
                sleepsecs(1);
            }
        }

        changeState(MemberState::RS_STARTUP2);
        startThreads();
        newReplUp(); // oplog.cpp
    }
 void ReplicationCoordinatorExternalStateImpl::startThreads() {
     _backgroundSyncThread.reset(new boost::thread(runSyncThread));
     BackgroundSync* bgsync = BackgroundSync::get();
     _producerThread.reset(new boost::thread(stdx::bind(&BackgroundSync::producerThread,
                                                        bgsync)));
     _syncSourceFeedbackThread.reset(new boost::thread(stdx::bind(&SyncSourceFeedback::run,
                                                                  &_syncSourceFeedback)));
     newReplUp();
 }
示例#3
0
    // call after constructing to start - returns fairly quickly after launching its threads
    void ReplSetImpl::_go() {
        OperationContextImpl txn;

        try {
            // Note: this sets lastOpTimeWritten, which the Applier uses to determine whether to
            // do an initial sync or not.
            loadLastOpTimeWritten(&txn);
        }
        catch (std::exception& e) {
            log() << "replSet error fatal couldn't query the local " << rsoplog
                  << " collection.  Terminating mongod after 30 seconds." << rsLog;
            log() << e.what() << rsLog;
            sleepsecs(30);
            dbexit(EXIT_REPLICATION_ERROR);
            return;
        }

        // initialize _me in SyncSourceFeedback
        bool meEnsured = false;
        while (!inShutdown() && !meEnsured) {
            try {
                syncSourceFeedback.ensureMe(&txn);
                meEnsured = true;
            }
            catch (const DBException& e) {
                warning() << "failed to write to local.me: " << e.what()
                          << " trying again in one second";
                sleepsecs(1);
            }
        }


        bool worked = getGlobalReplicationCoordinator()->setFollowerMode(MemberState::RS_STARTUP2);
        invariant(worked);
        startThreads();
        newReplUp(); // oplog.cpp
    }