summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatt dannenberg <matt.dannenberg@10gen.com>2016-02-07 16:04:18 -0500
committermatt dannenberg <matt.dannenberg@10gen.com>2016-02-09 14:19:26 -0500
commitd84483b8a6a9890c2c93f267d8c28969dc563c37 (patch)
tree61d3a4e4934a5cbe45e1679e8ac8eef9ce470467
parent8fce2322ec5a85181792cbf8a950e1ac14805578 (diff)
downloadmongo-renamerequestvotes.tar.gz
SERVER-22505 describe RequestVotes OpTime as durable rather than committedrenamerequestvotes
-rw-r--r--src/mongo/db/repl/repl_set_request_votes_args.cpp14
-rw-r--r--src/mongo/db/repl/repl_set_request_votes_args.h8
-rw-r--r--src/mongo/db/repl/topology_coordinator_impl.cpp2
-rw-r--r--src/mongo/db/repl/vote_requester.cpp13
-rw-r--r--src/mongo/db/repl/vote_requester.h6
5 files changed, 21 insertions, 22 deletions
diff --git a/src/mongo/db/repl/repl_set_request_votes_args.cpp b/src/mongo/db/repl/repl_set_request_votes_args.cpp
index 0041e78c4b2..3d55af3f93c 100644
--- a/src/mongo/db/repl/repl_set_request_votes_args.cpp
+++ b/src/mongo/db/repl/repl_set_request_votes_args.cpp
@@ -40,7 +40,9 @@ const std::string kCandidateIndexFieldName = "candidateIndex";
const std::string kCommandName = "replSetRequestVotes";
const std::string kConfigVersionFieldName = "configVersion";
const std::string kDryRunFieldName = "dryRun";
-const std::string kLastCommittedOpFieldName = "lastCommittedOp";
+// The underlying field name is inaccurate, but changing it requires a fair amount of cross
+// compatibility work for no real benefit.
+const std::string kLastDurableOpTimeFieldName = "lastCommittedOp";
const std::string kOkFieldName = "ok";
const std::string kReasonFieldName = "reason";
const std::string kSetNameFieldName = "setName";
@@ -52,7 +54,7 @@ const std::string kLegalArgsFieldNames[] = {
kCommandName,
kConfigVersionFieldName,
kDryRunFieldName,
- kLastCommittedOpFieldName,
+ kLastDurableOpTimeFieldName,
kSetNameFieldName,
kTermFieldName,
};
@@ -89,7 +91,7 @@ Status ReplSetRequestVotesArgs::initialize(const BSONObj& argsObj) {
if (!status.isOK())
return status;
- status = bsonExtractOpTimeField(argsObj, kLastCommittedOpFieldName, &_lastCommittedOp);
+ status = bsonExtractOpTimeField(argsObj, kLastDurableOpTimeFieldName, &_lastDurableOpTime);
if (!status.isOK())
return status;
@@ -112,8 +114,8 @@ long long ReplSetRequestVotesArgs::getConfigVersion() const {
return _cfgver;
}
-OpTime ReplSetRequestVotesArgs::getLastCommittedOp() const {
- return _lastCommittedOp;
+OpTime ReplSetRequestVotesArgs::getLastDurableOpTime() const {
+ return _lastDurableOpTime;
}
bool ReplSetRequestVotesArgs::isADryRun() const {
@@ -127,7 +129,7 @@ void ReplSetRequestVotesArgs::addToBSON(BSONObjBuilder* builder) const {
builder->append(kTermFieldName, _term);
builder->appendIntOrLL(kCandidateIndexFieldName, _candidateIndex);
builder->appendIntOrLL(kConfigVersionFieldName, _cfgver);
- _lastCommittedOp.append(builder, kLastCommittedOpFieldName);
+ _lastDurableOpTime.append(builder, kLastDurableOpTimeFieldName);
}
Status ReplSetRequestVotesResponse::initialize(const BSONObj& argsObj) {
diff --git a/src/mongo/db/repl/repl_set_request_votes_args.h b/src/mongo/db/repl/repl_set_request_votes_args.h
index 12541650798..7f1cf3bc72e 100644
--- a/src/mongo/db/repl/repl_set_request_votes_args.h
+++ b/src/mongo/db/repl/repl_set_request_votes_args.h
@@ -46,7 +46,7 @@ public:
long long getTerm() const;
long long getCandidateIndex() const;
long long getConfigVersion() const;
- OpTime getLastCommittedOp() const;
+ OpTime getLastDurableOpTime() const;
bool isADryRun() const;
void addToBSON(BSONObjBuilder* builder) const;
@@ -56,9 +56,9 @@ private:
long long _term = -1; // Current known term of the command issuer.
// replSet config index of the member who sent the replSetRequestVotesCmd.
long long _candidateIndex = -1;
- long long _cfgver = -1; // replSet config version known to the command issuer.
- OpTime _lastCommittedOp; // The last known committed op of the command issuer.
- bool _dryRun = false; // Indicates this is a pre-election check when true.
+ long long _cfgver = -1; // replSet config version known to the command issuer.
+ OpTime _lastDurableOpTime; // The last known durable op of the command issuer.
+ bool _dryRun = false; // Indicates this is a pre-election check when true.
};
class ReplSetRequestVotesResponse {
diff --git a/src/mongo/db/repl/topology_coordinator_impl.cpp b/src/mongo/db/repl/topology_coordinator_impl.cpp
index b67700251dc..0d1cb2cd981 100644
--- a/src/mongo/db/repl/topology_coordinator_impl.cpp
+++ b/src/mongo/db/repl/topology_coordinator_impl.cpp
@@ -2396,7 +2396,7 @@ void TopologyCoordinatorImpl::processReplSetRequestVotes(const ReplSetRequestVot
} else if (args.getSetName() != _rsConfig.getReplSetName()) {
response->setVoteGranted(false);
response->setReason("candidate's set name differs from mine");
- } else if (args.getLastCommittedOp() < lastAppliedOpTime) {
+ } else if (args.getLastDurableOpTime() < lastAppliedOpTime) {
response->setVoteGranted(false);
response->setReason("candidate's data is staler than mine");
} else if (!args.isADryRun() && _lastVote.getTerm() == args.getTerm()) {
diff --git a/src/mongo/db/repl/vote_requester.cpp b/src/mongo/db/repl/vote_requester.cpp
index 06df2e289c5..eafa68715e2 100644
--- a/src/mongo/db/repl/vote_requester.cpp
+++ b/src/mongo/db/repl/vote_requester.cpp
@@ -48,12 +48,12 @@ VoteRequester::Algorithm::Algorithm(const ReplicaSetConfig& rsConfig,
long long candidateIndex,
long long term,
bool dryRun,
- OpTime lastOplogEntry)
+ OpTime lastDurableOpTime)
: _rsConfig(rsConfig),
_candidateIndex(candidateIndex),
_term(term),
_dryRun(dryRun),
- _lastOplogEntry(lastOplogEntry) {
+ _lastDurableOpTime(lastDurableOpTime) {
// populate targets with all voting members that aren't this node
long long index = 0;
for (auto member = _rsConfig.membersBegin(); member != _rsConfig.membersEnd(); member++) {
@@ -75,10 +75,7 @@ std::vector<RemoteCommandRequest> VoteRequester::Algorithm::getRequests() const
requestVotesCmdBuilder.append("candidateIndex", _candidateIndex);
requestVotesCmdBuilder.append("configVersion", _rsConfig.getConfigVersion());
- BSONObjBuilder lastCommittedOp(requestVotesCmdBuilder.subobjStart("lastCommittedOp"));
- lastCommittedOp.append("ts", _lastOplogEntry.getTimestamp());
- lastCommittedOp.append("t", _lastOplogEntry.getTerm());
- lastCommittedOp.done();
+ _lastDurableOpTime.append(&requestVotesCmdBuilder, "lastCommittedOp");
const BSONObj requestVotesCmd = requestVotesCmdBuilder.obj();
@@ -150,9 +147,9 @@ StatusWith<ReplicationExecutor::EventHandle> VoteRequester::start(
long long candidateIndex,
long long term,
bool dryRun,
- OpTime lastOplogEntry,
+ OpTime lastDurableOpTime,
const stdx::function<void()>& onCompletion) {
- _algorithm.reset(new Algorithm(rsConfig, candidateIndex, term, dryRun, lastOplogEntry));
+ _algorithm.reset(new Algorithm(rsConfig, candidateIndex, term, dryRun, lastDurableOpTime));
_runner.reset(new ScatterGatherRunner(_algorithm.get()));
return _runner->start(executor, onCompletion);
}
diff --git a/src/mongo/db/repl/vote_requester.h b/src/mongo/db/repl/vote_requester.h
index 8ee9b052d4d..433facf345c 100644
--- a/src/mongo/db/repl/vote_requester.h
+++ b/src/mongo/db/repl/vote_requester.h
@@ -65,7 +65,7 @@ public:
long long candidateIndex,
long long term,
bool dryRun,
- OpTime lastOplogEntry);
+ OpTime lastDurableOpTime);
virtual ~Algorithm();
virtual std::vector<executor::RemoteCommandRequest> getRequests() const;
virtual void processResponse(const executor::RemoteCommandRequest& request,
@@ -89,7 +89,7 @@ public:
const long long _candidateIndex;
const long long _term;
bool _dryRun = false; // this bool indicates this is a mock election when true
- const OpTime _lastOplogEntry;
+ const OpTime _lastDurableOpTime;
std::vector<HostAndPort> _targets;
unordered_set<HostAndPort> _responders;
bool _staleTerm = false;
@@ -115,7 +115,7 @@ public:
long long candidateIndex,
long long term,
bool dryRun,
- OpTime lastOplogEntry,
+ OpTime lastDurableOpTime,
const stdx::function<void()>& onCompletion = stdx::function<void()>());
/**