diff options
author | Judah Schvimer <judah@mongodb.com> | 2016-10-24 14:47:35 -0400 |
---|---|---|
committer | Judah Schvimer <judah@mongodb.com> | 2016-10-26 11:52:12 -0400 |
commit | 67994f33a88f4aa70283e155c75f48ce997ccdc3 (patch) | |
tree | d6388e9fdc203444e8dedce3ae8f6c5378413284 /src/mongo/db/repl/data_replicator.cpp | |
parent | 6d183707d5de7d246f9fc6dba55d9011a39cfc5f (diff) | |
download | mongo-67994f33a88f4aa70283e155c75f48ce997ccdc3.tar.gz |
SERVER-26572 move fetchCount to DataReplicator
Diffstat (limited to 'src/mongo/db/repl/data_replicator.cpp')
-rw-r--r-- | src/mongo/db/repl/data_replicator.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/mongo/db/repl/data_replicator.cpp b/src/mongo/db/repl/data_replicator.cpp index 811e57f9df7..94d03d631e1 100644 --- a/src/mongo/db/repl/data_replicator.cpp +++ b/src/mongo/db/repl/data_replicator.cpp @@ -247,7 +247,8 @@ DataReplicator::DataReplicator( DataReplicatorOptions opts, std::unique_ptr<DataReplicatorExternalState> dataReplicatorExternalState, StorageInterface* storage) - : _opts(opts), + : _fetchCount(0), + _opts(opts), _dataReplicatorExternalState(std::move(dataReplicatorExternalState)), _exec(_dataReplicatorExternalState->getTaskExecutor()), _state(DataReplicatorState::Uninitialized), @@ -1216,9 +1217,11 @@ void DataReplicator::_onApplyBatchFinish(const Status& status, } } - int fetchedDocs = _dataReplicatorExternalState->getApplierFetchCount(); - if (fetchedDocs > 0) { - _onFetchMissingDocument_inlock(fetchedDocs, lastApplied, numApplied); + auto fetchCount = _fetchCount.load(); + if (fetchCount > 0) { + _initialSyncState->fetchedMissingDocs += fetchCount; + _fetchCount.store(0); + _onFetchMissingDocument_inlock(lastApplied, numApplied); // TODO (SERVER-25662): Remove this line. _applierPaused = true; return; @@ -1245,12 +1248,8 @@ void DataReplicator::_onApplyBatchFinish(const Status& status, _doNextActions(); } -void DataReplicator::_onFetchMissingDocument_inlock(int fetchedDocs, - OpTimeWithHash lastApplied, +void DataReplicator::_onFetchMissingDocument_inlock(OpTimeWithHash lastApplied, std::size_t numApplied) { - _initialSyncState->fetchedMissingDocs += fetchedDocs; - _dataReplicatorExternalState->resetSyncSourceHostAndFetchCount(_syncSource); - _scheduleLastOplogEntryFetcher_inlock([this, lastApplied, numApplied]( const QueryResponseStatus& fetchResult, Fetcher::NextAction*, BSONObjBuilder*) { auto&& lastOplogEntryOpTimeWithHashStatus = parseOpTimeWithHash(fetchResult); @@ -1334,11 +1333,14 @@ Status DataReplicator::_scheduleApplyBatch_inlock(const Operations& ops) { stdx::placeholders::_1); } else { invariant(_state == DataReplicatorState::InitialSync); + _fetchCount.store(0); // "_syncSource" has to be copied to stdx::bind result. - _dataReplicatorExternalState->resetSyncSourceHostAndFetchCount(_syncSource); + HostAndPort source = _syncSource; applierFn = stdx::bind(&DataReplicatorExternalState::_multiInitialSyncApply, _dataReplicatorExternalState.get(), - stdx::placeholders::_1); + stdx::placeholders::_1, + source, + &_fetchCount); } auto multiApplyFn = stdx::bind(&DataReplicatorExternalState::_multiApply, |