Skip to content

Commit

Permalink
[improve] ignore PreVoteRequest when not in conf (sofastack#510)
Browse files Browse the repository at this point in the history
* ignore PreVoteRequest when not in conf

* always check replicator
  • Loading branch information
fengjiachun authored Sep 24, 2020
1 parent 7fdf7ec commit 4bd2a82
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1650,6 +1650,11 @@ public Message handlePreVoteRequest(final RequestVoteRequest request) {
boolean granted = false;
// noinspection ConstantConditions
do {
if (!this.conf.contains(candidateId)) {
LOG.warn("Node {} ignore PreVoteRequest from {} as it is not in conf <{}>.", getNodeId(),
request.getServerId(), this.conf);
break;
}
if (this.leaderId != null && !this.leaderId.isEmpty() && isCurrentLeaderValid()) {
LOG.info(
"Node {} ignore PreVoteRequest from {}, term={}, currTerm={}, because the leader {}'s lease is still valid.",
Expand All @@ -1662,11 +1667,11 @@ public Message handlePreVoteRequest(final RequestVoteRequest request) {
// A follower replicator may not be started when this node become leader, so we must check it.
checkReplicator(candidateId);
break;
} else if (request.getTerm() == this.currTerm + 1) {
// A follower replicator may not be started when this node become leader, so we must check it.
// check replicator state
checkReplicator(candidateId);
}
// A follower replicator may not be started when this node become leader, so we must check it.
// check replicator state
checkReplicator(candidateId);

doUnlock = false;
this.writeLock.unlock();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ public synchronized void start() {
.withInitialServerList(initialServerList).withOnlyLeaderRead(this.onlyLeaderRead) //
.withStoreEngineOptions(storeOpts) //
.withPlacementDriverOptions(pdOpts) //
.withFailoverRetries(10) //
.withFutureTimeoutMillis(TimeUnit.SECONDS.toMillis(30)) //
.withFailoverRetries(30) //
.withFutureTimeoutMillis(TimeUnit.SECONDS.toMillis(60)) //
.config();
BatchingOptions batchingOptions = opts.getBatchingOptions();
if (batchingOptions == null) {
Expand Down

0 comments on commit 4bd2a82

Please sign in to comment.