diff options
author | Benety Goh <benety@mongodb.com> | 2016-06-24 15:06:21 -0400 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2016-06-27 17:02:35 -0400 |
commit | 7fb4f0c57126bab6a0d2ea01d7e76926f64ca1e3 (patch) | |
tree | 463a5d96c5742c189f196c877125512da24c152a /src/mongo/db/repl/replication_coordinator_external_state_impl.cpp | |
parent | 00e103fc3a5264c098536f303b6bbda2bf5c868e (diff) | |
download | mongo-7fb4f0c57126bab6a0d2ea01d7e76926f64ca1e3.tar.gz |
SERVER-24784 syncDoInitialSync maintains its own instance of BackgroundSync
Diffstat (limited to 'src/mongo/db/repl/replication_coordinator_external_state_impl.cpp')
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_external_state_impl.cpp | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp index ef5fe93d4f4..58a83b41cb6 100644 --- a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp @@ -151,22 +151,8 @@ bool ReplicationCoordinatorExternalStateImpl::isInitialSyncFlagSet(OperationCont void ReplicationCoordinatorExternalStateImpl::startInitialSync(OnInitialSyncFinishedFn finished) { _initialSyncThread.reset(new stdx::thread{[finished, this]() { Client::initThreadIfNotAlready("initial sync"); - - // "_bgSync" should not be initialized before this. - invariant(!_bgSync); - { - auto txn = cc().makeOperationContext(); - invariant(txn); - invariant(txn->getClient()); - log() << "Starting replication fetcher thread"; - - // Start bgsync. - _bgSync.reset(new BackgroundSync(this, makeSteadyStateOplogBuffer(txn.get()))); - _bgSync->startup(txn.get()); - } - // Do initial sync. - syncDoInitialSync(_bgSync.get()); + syncDoInitialSync(this); finished(); }}); } @@ -183,11 +169,11 @@ void ReplicationCoordinatorExternalStateImpl::runOnInitialSyncThread( } void ReplicationCoordinatorExternalStateImpl::startSteadyStateReplication(OperationContext* txn) { - if (!_bgSync) { - log() << "Starting replication fetcher thread"; - _bgSync.reset(new BackgroundSync(this, makeSteadyStateOplogBuffer(txn))); - _bgSync->startup(txn); - } + invariant(!_bgSync); + log() << "Starting replication fetcher thread"; + _bgSync = stdx::make_unique<BackgroundSync>(this, makeSteadyStateOplogBuffer(txn)); + _bgSync->startup(txn); + log() << "Starting replication applier threads"; invariant(!_applierThread); _applierThread.reset(new stdx::thread(stdx::bind(&runSyncThread, _bgSync.get()))); |