summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/sync_source_resolver.h
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2016-11-15 15:24:22 -0500
committerMathias Stearn <mathias@10gen.com>2017-01-03 16:02:19 -0500
commit0b76764eac7651ddba4c82c504aa7e8d785087c2 (patch)
treef90fce58d2781a48afaee696ee3fb9e6f8fefedc /src/mongo/db/repl/sync_source_resolver.h
parent506c8af1269c76fcd730e121e37b82a18347ac70 (diff)
downloadmongo-0b76764eac7651ddba4c82c504aa7e8d785087c2.tar.gz
SERVER-27050 Ensure upstream node doesn't roll back after checking MinValid
Diffstat (limited to 'src/mongo/db/repl/sync_source_resolver.h')
-rw-r--r--src/mongo/db/repl/sync_source_resolver.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/mongo/db/repl/sync_source_resolver.h b/src/mongo/db/repl/sync_source_resolver.h
index 099b56994e2..48f7e968a8d 100644
--- a/src/mongo/db/repl/sync_source_resolver.h
+++ b/src/mongo/db/repl/sync_source_resolver.h
@@ -70,6 +70,11 @@ struct SyncSourceResolverResponse {
// Contains the new MinValid boundry if syncSourceStatus is ErrorCodes::OplogStartMissing.
OpTime earliestOpTimeSeen;
+ // Rollback ID of the selected sync source. Only filled in when there is a required optime.
+ // The rbid is fetched before the required optime so callers can be sure that as long as the
+ // rbid is the same, the required optime is still present.
+ boost::optional<int> rbid;
+
bool isOK() {
return syncSourceStatus.isOK();
}
@@ -172,6 +177,14 @@ private:
OpTime earliestOpTimeSeen);
/**
+ * Schedules a replSetGetRBID command against the candidate to fetch its current rollback id.
+ */
+ void _scheduleRBIDRequest(HostAndPort candidate, OpTime earliestOpTimeSeen);
+ void _rbidRequestCallback(HostAndPort candidate,
+ OpTime earliestOpTimeSeen,
+ const executor::TaskExecutor::RemoteCommandCallbackArgs& rbidReply);
+
+ /**
* Checks query response for required optime.
*/
Status _compareRequiredOpTimeWithQueryResponse(const Fetcher::QueryResponse& queryResponse);
@@ -216,7 +229,10 @@ private:
// resolver via this callback in a SyncSourceResolverResponse struct when the resolver finishes.
const OnCompletionFn _onCompletion;
- // Protects members of this sync source resolver.
+ // The rbid we will return to our caller.
+ boost::optional<int> _rbid;
+
+ // Protects members of this sync source resolver defined below.
mutable stdx::mutex _mutex;
mutable stdx::condition_variable _condition;
@@ -233,6 +249,8 @@ private:
// Holds reference to fetcher in the process of shutting down.
std::unique_ptr<Fetcher> _shuttingDownFetcher;
+
+ executor::TaskExecutor::CallbackHandle _rbidCommandHandle;
};
} // namespace repl