예제 #1
0
    void BackgroundSync::producerThread() {
        Client::initThread("rsBackgroundSync");
        replLocalAuth();

        while (!inShutdown()) {
            if (!theReplSet) {
                log() << "replSet warning did not receive a valid config yet, sleeping 20 seconds " << rsLog;
                sleepsecs(20);
                continue;
            }

            try {
                _producerThread();
            }
            catch (DBException& e) {
                sethbmsg(str::stream() << "db exception in producer: " << e.toString());
                sleepsecs(10);
            }
            catch (std::exception& e2) {
                sethbmsg(str::stream() << "exception in producer: " << e2.what());
                sleepsecs(60);
            }
        }

        cc().shutdown();
    }
예제 #2
0
void BackgroundSync::producerThread() {
    Client::initThread("rsBackgroundSync");
    AuthorizationSession::get(cc())->grantInternalAuthorization();

    _threadPoolTaskExecutor.startup();
    ON_BLOCK_EXIT([this]() {
        _threadPoolTaskExecutor.shutdown();
        _threadPoolTaskExecutor.join();
    });

    while (!inShutdown()) {
        try {
            _producerThread();
        } catch (const DBException& e) {
            std::string msg(str::stream() << "sync producer problem: " << e.toString());
            error() << msg;
            _replCoord->setMyHeartbeatMessage(msg);
            sleepmillis(100);  // sleep a bit to keep from hammering this thread with temp. errors.
        } catch (const std::exception& e2) {
            severe() << "sync producer exception: " << e2.what();
            fassertFailed(28546);
        }
    }
    stop();
}
예제 #3
0
파일: bgsync.cpp 프로젝트: alabid/mongo
void BackgroundSync::producerThread(executor::TaskExecutor* taskExecutor) {
    Client::initThread("rsBackgroundSync");
    AuthorizationSession::get(cc())->grantInternalAuthorization();

    // Disregard task executor passed into this function and use a local thread pool task executor
    // instead. This ensures that potential blocking operations inside the fetcher callback will
    // not affect other coordinators (such as the replication coordinator) that might be dependent
    // on the shared task executor.
    ThreadPool::Options threadPoolOptions;
    threadPoolOptions.poolName = "rsBackgroundSync";
    executor::ThreadPoolTaskExecutor threadPoolTaskExecutor(
        stdx::make_unique<ThreadPool>(threadPoolOptions), executor::makeNetworkInterface());
    taskExecutor = &threadPoolTaskExecutor;
    taskExecutor->startup();
    ON_BLOCK_EXIT([taskExecutor]() {
        taskExecutor->shutdown();
        taskExecutor->join();
    });

    while (!inShutdown()) {
        try {
            _producerThread(taskExecutor);
        } catch (const DBException& e) {
            std::string msg(str::stream() << "sync producer problem: " << e.toString());
            error() << msg;
            _replCoord->setMyHeartbeatMessage(msg);
        } catch (const std::exception& e2) {
            severe() << "sync producer exception: " << e2.what();
            fassertFailed(28546);
        }
    }
}
예제 #4
0
파일: bgsync.cpp 프로젝트: ArgusTek/mongo
    void BackgroundSync::producerThread() {
        Client::initThread("rsBackgroundSync");
        AuthorizationSession::get(cc())->grantInternalAuthorization();

        while (!inShutdown()) {
            try {
                _producerThread();
            }
            catch (const DBException& e) {
                std::string msg(str::stream() << "sync producer problem: " << e.toString());
                error() << msg;
                _replCoord->setMyHeartbeatMessage(msg);
            }
            catch (const std::exception& e2) {
                severe() << "sync producer exception: " << e2.what();
                fassertFailed(28546);
            }
        }
    }