diff options
author | Spencer T Brody <spencer@mongodb.com> | 2016-12-15 18:07:51 -0500 |
---|---|---|
committer | Spencer T Brody <spencer@mongodb.com> | 2017-01-04 16:00:25 -0500 |
commit | 87f49488f1b5c872daa71fd2fd9b5d744409a817 (patch) | |
tree | 38f4d3eaf16f933c9cfc184501f6e0068be807f1 /src/mongo/db/repl/oplog_fetcher.cpp | |
parent | a59962fab548e695f2e0efa2f261381cba771551 (diff) | |
download | mongo-87f49488f1b5c872daa71fd2fd9b5d744409a817.tar.gz |
SERVER-27123 Only update the commit point as a secondary from oplog queries against your sync source
Diffstat (limited to 'src/mongo/db/repl/oplog_fetcher.cpp')
-rw-r--r-- | src/mongo/db/repl/oplog_fetcher.cpp | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/src/mongo/db/repl/oplog_fetcher.cpp b/src/mongo/db/repl/oplog_fetcher.cpp index 7e31eb598d5..61169fa1a68 100644 --- a/src/mongo/db/repl/oplog_fetcher.cpp +++ b/src/mongo/db/repl/oplog_fetcher.cpp @@ -433,24 +433,6 @@ void OplogFetcher::_callback(const Fetcher::QueryResponseStatus& result, } const auto& queryResponse = result.getValue(); - rpc::ReplSetMetadata metadata; - - // Forward metadata (containing liveness information) to data replicator external state. - bool receivedMetadata = - queryResponse.otherFields.metadata.hasElement(rpc::kReplSetMetadataFieldName); - if (receivedMetadata) { - const auto& metadataObj = queryResponse.otherFields.metadata; - auto metadataResult = rpc::ReplSetMetadata::readFromMetadata(metadataObj); - if (!metadataResult.isOK()) { - error() << "invalid replication metadata from sync source " << _fetcher->getSource() - << ": " << metadataResult.getStatus() << ": " << metadataObj; - _finishCallback(metadataResult.getStatus()); - return; - } - metadata = metadataResult.getValue(); - _dataReplicatorExternalState->processMetadata(metadata); - } - const auto& documents = queryResponse.documents; auto firstDocToApply = documents.cbegin(); @@ -487,6 +469,25 @@ void OplogFetcher::_callback(const Fetcher::QueryResponseStatus& result, } auto info = validateResult.getValue(); + // Process replset metadata. It is important that this happen after we've validated the + // first batch, so we don't progress our knowledge of the commit point from a + // response that triggers a rollback. + rpc::ReplSetMetadata metadata; + bool receivedMetadata = + queryResponse.otherFields.metadata.hasElement(rpc::kReplSetMetadataFieldName); + if (receivedMetadata) { + const auto& metadataObj = queryResponse.otherFields.metadata; + auto metadataResult = rpc::ReplSetMetadata::readFromMetadata(metadataObj); + if (!metadataResult.isOK()) { + error() << "invalid replication metadata from sync source " << _fetcher->getSource() + << ": " << metadataResult.getStatus() << ": " << metadataObj; + _finishCallback(metadataResult.getStatus()); + return; + } + metadata = metadataResult.getValue(); + _dataReplicatorExternalState->processMetadata(metadata); + } + // Increment stats. We read all of the docs in the query. opsReadStats.increment(info.networkDocumentCount); networkByteStats.increment(info.networkDocumentBytes); |