Ejemplo n.º 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
    }
Ejemplo n.º 2
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
    }