You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by ta...@apache.org on 2024/09/13 02:28:40 UTC
(ratis) branch release-3.1.1 updated (342688de9 -> 356ad8a27)
This is an automated email from the ASF dual-hosted git repository.
tanxinyu pushed a change to branch release-3.1.1
in repository https://gitbox.apache.org/repos/asf/ratis.git
from 342688de9 RATIS-2153. ratis-version.properties missing from src bundle (#1147)
new 1e10b7186 RATIS-2149.Do not perform leader election if the current RaftServer has not started yet (#1143)
new 54a991623 RATIS-2148. Snapshot transfer may cause followers to trigger reloadStateMachine incorrectly (#1145)
new 5578be7fb RATIS-2154. The old leader may send appendEntries after term changed. (#1148)
new f23f9b7c1 RATIS-2152. GrpcLogAppender stucks while sending an installSnapshot notification request (#1146)
new 356ad8a27 RATIS-2150. No need for manual assembly:single execution when mvn deploy #1144
The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
dev-support/make_rc.sh | 2 +-
.../apache/ratis/grpc/server/GrpcLogAppender.java | 34 +++++++++-------------
.../apache/ratis/server/impl/LeaderElection.java | 4 +++
.../apache/ratis/server/impl/RaftServerImpl.java | 10 +++++--
.../server/impl/SnapshotInstallationHandler.java | 10 +++++++
5 files changed, 36 insertions(+), 24 deletions(-)
(ratis) 03/05: RATIS-2154. The old leader may send appendEntries after term changed. (#1148)
Posted by ta...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tanxinyu pushed a commit to branch release-3.1.1
in repository https://gitbox.apache.org/repos/asf/ratis.git
commit 5578be7fb07e52cfa90e2979fd251ae78badfc62
Author: 133tosakarin <97...@users.noreply.github.com>
AuthorDate: Thu Sep 12 23:42:06 2024 +0800
RATIS-2154. The old leader may send appendEntries after term changed. (#1148)
---
.../src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
index a66c8ec5f..0473564b3 100644
--- a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
+++ b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
@@ -571,11 +571,10 @@ class RaftServerImpl implements RaftServer.Division,
boolean allowListener,
Object reason) {
final RaftPeerRole old = role.getCurrentRole();
- final boolean metadataUpdated = state.updateCurrentTerm(newTerm);
if (old == RaftPeerRole.LISTENER && !allowListener) {
throw new IllegalStateException("Unexpected role " + old);
}
-
+ boolean metadataUpdated;
if ((old != RaftPeerRole.FOLLOWER || force) && old != RaftPeerRole.LISTENER) {
setRole(RaftPeerRole.FOLLOWER, reason);
if (old == RaftPeerRole.LEADER) {
@@ -596,8 +595,11 @@ class RaftServerImpl implements RaftServer.Division,
} else if (old == RaftPeerRole.FOLLOWER) {
role.shutdownFollowerState();
}
+ metadataUpdated = state.updateCurrentTerm(newTerm);
role.startFollowerState(this, reason);
setFirstElection(reason);
+ } else {
+ metadataUpdated = state.updateCurrentTerm(newTerm);
}
return metadataUpdated;
}
(ratis) 05/05: RATIS-2150. No need for manual assembly:single execution when mvn deploy #1144
Posted by ta...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tanxinyu pushed a commit to branch release-3.1.1
in repository https://gitbox.apache.org/repos/asf/ratis.git
commit 356ad8a27ffead990a4fc6108ffc6df8f3d2c58b
Author: Potato <ta...@apache.org>
AuthorDate: Fri Sep 13 10:16:56 2024 +0800
RATIS-2150. No need for manual assembly:single execution when mvn deploy #1144
Signed-off-by: OneSizeFitQuorum <ta...@apache.org>
---
dev-support/make_rc.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dev-support/make_rc.sh b/dev-support/make_rc.sh
index 64a6d3d41..fa6a2662a 100755
--- a/dev-support/make_rc.sh
+++ b/dev-support/make_rc.sh
@@ -147,7 +147,7 @@ publish-svn() {
publish-mvn(){
cd "$projectdir"
- mvnFun -X clean deploy assembly:single -DskipTests=true -Prelease -Papache-release -Dgpg.keyname="${CODESIGNINGKEY}"
+ mvnFun -X clean deploy -DskipTests=true -Prelease -Papache-release -Dgpg.keyname="${CODESIGNINGKEY}"
}
if [ "$#" -ne 1 ]; then
(ratis) 04/05: RATIS-2152. GrpcLogAppender stucks while sending an installSnapshot notification request (#1146)
Posted by ta...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tanxinyu pushed a commit to branch release-3.1.1
in repository https://gitbox.apache.org/repos/asf/ratis.git
commit f23f9b7c10b3d96efc53a478e811d5c94f9d8a20
Author: Chung En Lee <wf...@gmail.com>
AuthorDate: Fri Sep 13 00:26:57 2024 +0800
RATIS-2152. GrpcLogAppender stucks while sending an installSnapshot notification request (#1146)
---
.../apache/ratis/grpc/server/GrpcLogAppender.java | 34 +++++++++-------------
1 file changed, 13 insertions(+), 21 deletions(-)
diff --git a/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java b/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java
index 0229f8e84..192bc7564 100644
--- a/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java
+++ b/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java
@@ -54,8 +54,8 @@ import java.io.InterruptedIOException;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
/**
@@ -567,7 +567,7 @@ public class GrpcLogAppender extends LogAppenderBase {
private class InstallSnapshotResponseHandler implements StreamObserver<InstallSnapshotReplyProto> {
private final String name = getFollower().getName() + "-" + JavaUtils.getClassSimpleName(getClass());
private final Queue<Integer> pending;
- private final AtomicBoolean done = new AtomicBoolean(false);
+ private final CompletableFuture<Void> done = new CompletableFuture<>();
private final boolean isNotificationOnly;
InstallSnapshotResponseHandler() {
@@ -628,12 +628,18 @@ public class GrpcLogAppender extends LogAppenderBase {
getServer().getStateMachine().event().notifySnapshotInstalled(result, snapshotIndex, getFollower().getPeer());
}
- boolean isDone() {
- return done.get();
+ void waitForResponse() {
+ try {
+ done.get();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ } catch (ExecutionException e) {
+ throw new IllegalStateException("Failed to complete " + name, e);
+ }
}
void close() {
- done.set(true);
+ done.complete(null);
notifyLogAppender();
}
@@ -767,14 +773,7 @@ public class GrpcLogAppender extends LogAppenderBase {
}
return;
}
-
- while (isRunning() && !responseHandler.isDone()) {
- try {
- getEventAwaitForSignal().await(getWaitTimeMs(), TimeUnit.MILLISECONDS);
- } catch (InterruptedException ignored) {
- Thread.currentThread().interrupt();
- }
- }
+ responseHandler.waitForResponse();
if (responseHandler.hasAllResponse()) {
getFollower().setSnapshotIndex(snapshot.getTermIndex().getIndex());
@@ -812,14 +811,7 @@ public class GrpcLogAppender extends LogAppenderBase {
}
return;
}
-
- while (isRunning() && !responseHandler.isDone()) {
- try {
- getEventAwaitForSignal().await(getWaitTimeMs(), TimeUnit.MILLISECONDS);
- } catch (InterruptedException ignored) {
- Thread.currentThread().interrupt();
- }
- }
+ responseHandler.waitForResponse();
}
/**
(ratis) 01/05: RATIS-2149.Do not perform leader election if the current RaftServer has not started yet (#1143)
Posted by ta...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tanxinyu pushed a commit to branch release-3.1.1
in repository https://gitbox.apache.org/repos/asf/ratis.git
commit 1e10b7186fa7f4bea695cab01c82579af8fee66b
Author: 133tosakarin <97...@users.noreply.github.com>
AuthorDate: Sat Sep 7 10:56:42 2024 +0800
RATIS-2149.Do not perform leader election if the current RaftServer has not started yet (#1143)
---
.../src/main/java/org/apache/ratis/server/impl/LeaderElection.java | 4 ++++
.../src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderElection.java b/ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderElection.java
index da9c51348..af25ae912 100644
--- a/ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderElection.java
+++ b/ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderElection.java
@@ -241,6 +241,10 @@ class LeaderElection implements Runnable {
}
try (AutoCloseable ignored = Timekeeper.start(server.getLeaderElectionMetrics().getLeaderElectionTimer())) {
+ if (!server.isRunning()) {
+ LOG.info("{}: skip since the server is not running", this);
+ return;
+ }
for (int round = 0; shouldRun(); round++) {
if (skipPreVote || askForVotes(Phase.PRE_VOTE, round)) {
if (askForVotes(Phase.ELECTION, round)) {
diff --git a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
index c682de8bf..a66c8ec5f 100644
--- a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
+++ b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
@@ -1859,4 +1859,8 @@ class RaftServerImpl implements RaftServer.Division,
void onGroupLeaderElected() {
transferLeadership.complete(TransferLeadership.Result.SUCCESS);
}
+
+ boolean isRunning() {
+ return startComplete.get() && lifeCycle.getCurrentState() == State.RUNNING;
+ }
}
(ratis) 02/05: RATIS-2148. Snapshot transfer may cause followers to trigger reloadStateMachine incorrectly (#1145)
Posted by ta...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tanxinyu pushed a commit to branch release-3.1.1
in repository https://gitbox.apache.org/repos/asf/ratis.git
commit 54a991623ec34d8386cda18ec2c2951ccb08a70b
Author: 133tosakarin <97...@users.noreply.github.com>
AuthorDate: Sat Sep 7 10:29:47 2024 +0800
RATIS-2148. Snapshot transfer may cause followers to trigger reloadStateMachine incorrectly (#1145)
---
.../apache/ratis/server/impl/SnapshotInstallationHandler.java | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/ratis-server/src/main/java/org/apache/ratis/server/impl/SnapshotInstallationHandler.java b/ratis-server/src/main/java/org/apache/ratis/server/impl/SnapshotInstallationHandler.java
index 4a63e64ee..9b84e8f1d 100644
--- a/ratis-server/src/main/java/org/apache/ratis/server/impl/SnapshotInstallationHandler.java
+++ b/ratis-server/src/main/java/org/apache/ratis/server/impl/SnapshotInstallationHandler.java
@@ -47,6 +47,7 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
@@ -68,6 +69,7 @@ class SnapshotInstallationHandler {
new AtomicReference<>(INVALID_TERM_INDEX);
private final AtomicBoolean isSnapshotNull = new AtomicBoolean();
private final AtomicLong installedIndex = new AtomicLong(INVALID_LOG_INDEX);
+ private final AtomicInteger nextChunkIndex = new AtomicInteger(-1);
SnapshotInstallationHandler(RaftServerImpl server, RaftProperties properties) {
this.server = server;
@@ -172,6 +174,12 @@ class SnapshotInstallationHandler {
state.setLeader(leaderId, "installSnapshot");
server.updateLastRpcTime(FollowerState.UpdateType.INSTALL_SNAPSHOT_START);
+ if (snapshotChunkRequest.getRequestIndex() == 0) {
+ nextChunkIndex.set(0);
+ } else if (nextChunkIndex.get() != snapshotChunkRequest.getRequestIndex()) {
+ throw new IOException("Snapshot request already failed at chunk index " + nextChunkIndex.get()
+ + "; ignoring request with chunk index " + snapshotChunkRequest.getRequestIndex());
+ }
try {
// Check and append the snapshot chunk. We simply put this in lock
// considering a follower peer requiring a snapshot installation does not
@@ -184,6 +192,8 @@ class SnapshotInstallationHandler {
//TODO: We should only update State with installed snapshot once the request is done.
state.installSnapshot(request);
+ int idx = nextChunkIndex.getAndIncrement();
+ Preconditions.assertEquals(snapshotChunkRequest.getRequestIndex(), idx, "nextChunkIndex");
// update the committed index
// re-load the state machine if this is the last chunk
if (snapshotChunkRequest.getDone()) {