diff options
author | Samy Lanka <samy.lanka@mongodb.com> | 2019-01-14 20:49:48 -0500 |
---|---|---|
committer | Samy Lanka <samy.lanka@mongodb.com> | 2019-01-17 15:57:29 -0500 |
commit | d764e1b6346726fc2e9259ba294d029d531ff38e (patch) | |
tree | e50e5dc8a61f42f1cbcad1deb854adf98ede8693 /src/mongo/db/repl/oplog_fetcher.cpp | |
parent | 9e87f6e272df4f97013dfccc4018efb79f68653a (diff) | |
download | mongo-d764e1b6346726fc2e9259ba294d029d531ff38e.tar.gz |
SERVER-36815 Remove references to oplog entry's hash field
Diffstat (limited to 'src/mongo/db/repl/oplog_fetcher.cpp')
-rw-r--r-- | src/mongo/db/repl/oplog_fetcher.cpp | 55 |
1 files changed, 19 insertions, 36 deletions
diff --git a/src/mongo/db/repl/oplog_fetcher.cpp b/src/mongo/db/repl/oplog_fetcher.cpp index 0b0e0990ecc..7850334f478 100644 --- a/src/mongo/db/repl/oplog_fetcher.cpp +++ b/src/mongo/db/repl/oplog_fetcher.cpp @@ -111,7 +111,7 @@ BSONObj makeMetadataObject() { /** * Checks the first batch of results from query. * 'documents' are the first batch of results returned from tailing the remote oplog. - * 'lastFetched' optime and hash should be consistent with the predicate in the query. + * 'lastFetched' optime should be consistent with the predicate in the query. * 'lastOpCommitted' is the OpTime of the most recently committed op of which this node is aware. * 'remoteLastOpApplied' is the last OpTime applied on the sync source. This is optional for * compatibility with 3.4 servers that do not send OplogQueryMetadata. @@ -132,7 +132,7 @@ BSONObj makeMetadataObject() { * the remote oplog. */ Status checkRemoteOplogStart(const Fetcher::Documents& documents, - OpTimeWithHash lastFetched, + OpTime lastFetched, OpTime lastOpCommitted, boost::optional<OpTime> remoteLastOpApplied, boost::optional<OpTime> remoteLastOpCommitted, @@ -163,12 +163,12 @@ Status checkRemoteOplogStart(const Fetcher::Documents& documents, // failed to detect the rollback if it occurred between sync source selection (when we check the // candidate is ahead of us) and sync source resolution (when we got 'requiredRBID'). If the // sync source is now behind us, choose a new sync source to prevent going into rollback. - if (remoteLastOpApplied && (*remoteLastOpApplied < lastFetched.opTime)) { + if (remoteLastOpApplied && (*remoteLastOpApplied < lastFetched)) { return Status(ErrorCodes::InvalidSyncSource, str::stream() << "Sync source's last applied OpTime " << remoteLastOpApplied->toString() << " is older than our last fetched OpTime " - << lastFetched.opTime.toString() + << lastFetched.toString() << ". Choosing new sync source."); } @@ -183,13 +183,13 @@ Status checkRemoteOplogStart(const Fetcher::Documents& documents, // OpTime to determine where to start our OplogFetcher. if (requireFresherSyncSource && remoteLastOpApplied && remoteLastOpCommitted && std::tie(*remoteLastOpApplied, *remoteLastOpCommitted) <= - std::tie(lastFetched.opTime, lastOpCommitted)) { + std::tie(lastFetched, lastOpCommitted)) { return Status(ErrorCodes::InvalidSyncSource, str::stream() << "Sync source cannot be behind me, and if I am up-to-date with the " "sync source, it must have a higher lastOpCommitted. " << "My last fetched oplog optime: " - << lastFetched.opTime.toString() + << lastFetched.toString() << ", latest oplog optime of sync source: " << remoteLastOpApplied->toString() << ", my lastOpCommitted: " @@ -212,33 +212,16 @@ Status checkRemoteOplogStart(const Fetcher::Documents& documents, auto opTimeResult = OpTime::parseFromOplogEntry(o); if (!opTimeResult.isOK()) { return Status(ErrorCodes::InvalidBSON, - str::stream() << "our last op time fetched: " << lastFetched.opTime.toString() - << " (hash: " - << lastFetched.value - << ")" + str::stream() << "our last optime fetched: " << lastFetched.toString() << ". failed to parse optime from first oplog on source: " << o.toString() << ": " << opTimeResult.getStatus().toString()); } auto opTime = opTimeResult.getValue(); - long long hash = o["h"].numberLong(); - if (opTime != lastFetched.opTime || hash != lastFetched.value) { - std::string message = str::stream() - << "Our last op time fetched: " << lastFetched.opTime.toString() - << ". source's GTE: " << opTime.toString() << " hashes: (" << lastFetched.value << "/" - << hash << ")"; - - // In PV1, if the hashes do not match, the optimes should not either since optimes uniquely - // identify oplog entries. In that case we fail before we potentially corrupt data. This - // should never happen. - if (opTime.getTerm() != OpTime::kUninitializedTerm && hash != lastFetched.value && - opTime == lastFetched.opTime) { - severe() << "Hashes do not match but OpTimes do. " << message - << ". Source's GTE doc: " << redact(o); - fassertFailedNoTrace(40634); - } - + if (opTime != lastFetched) { + std::string message = str::stream() << "Our last optime fetched: " << lastFetched.toString() + << ". source's GTE: " << opTime.toString(); return Status(ErrorCodes::OplogStartMissing, message); } return Status::OK(); @@ -292,14 +275,14 @@ StatusWith<OplogFetcher::DocumentsInfo> OplogFetcher::validateDocuments( continue; } - auto docOpTimeWithHash = AbstractOplogFetcher::parseOpTimeWithHash(doc); - if (!docOpTimeWithHash.isOK()) { - return docOpTimeWithHash.getStatus(); + auto docOpTime = OpTime::parseFromOplogEntry(doc); + if (!docOpTime.isOK()) { + return docOpTime.getStatus(); } - info.lastDocument = docOpTimeWithHash.getValue(); + info.lastDocument = docOpTime.getValue(); // Check to see if the oplog entry goes back in time for this document. - const auto docTS = info.lastDocument.opTime.getTimestamp(); + const auto docTS = info.lastDocument.getTimestamp(); if (lastTS >= docTS) { return Status(ErrorCodes::OplogOutOfOrder, str::stream() << "Out of order entries in oplog. lastTS: " @@ -330,7 +313,7 @@ StatusWith<OplogFetcher::DocumentsInfo> OplogFetcher::validateDocuments( } OplogFetcher::OplogFetcher(executor::TaskExecutor* executor, - OpTimeWithHash lastFetched, + OpTime lastFetched, HostAndPort source, NamespaceString nss, ReplSetConfig config, @@ -436,7 +419,7 @@ StatusWith<BSONObj> OplogFetcher::_onSuccessfulBatch(const Fetcher::QueryRespons auto oqMetadata = oqMetadataResult.getValue(); // This lastFetched value is the last OpTime from the previous batch. - auto lastFetched = _getLastOpTimeWithHashFetched(); + auto lastFetched = _getLastOpTimeFetched(); // Check start of remote oplog and, if necessary, stop fetcher to execute rollback. if (queryResponse.first) { @@ -465,8 +448,8 @@ StatusWith<BSONObj> OplogFetcher::_onSuccessfulBatch(const Fetcher::QueryRespons firstDocToApply++; } - auto validateResult = OplogFetcher::validateDocuments( - documents, queryResponse.first, lastFetched.opTime.getTimestamp()); + auto validateResult = + OplogFetcher::validateDocuments(documents, queryResponse.first, lastFetched.getTimestamp()); if (!validateResult.isOK()) { return validateResult.getStatus(); } |