You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by wi...@apache.org on 2025/01/09 03:06:44 UTC
(ratis) branch release-3.1.3 updated (0bd730e25 -> 7a38c9984)
This is an automated email from the ASF dual-hosted git repository.
williamsong pushed a change to branch release-3.1.3
in repository https://gitbox.apache.org/repos/asf/ratis.git
discard 0bd730e25 RATIS-2236 Fixed bug where manual triggerSnapshot would never finish (#1207)
discard 7ff4812dc RATIS-2235. Allow only one thread to perform appendLog (#1206)
new 3255448c4 RATIS-2236 Fixed bug where manual triggerSnapshot would never finish (#1207)
new 7a38c9984 RATIS-2235. Allow only one thread to perform appendLog (#1206)
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (0bd730e25)
\
N -- N -- N refs/heads/release-3.1.3 (7a38c9984)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 2 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:
.../src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java | 1 -
1 file changed, 1 deletion(-)
(ratis) 01/02: RATIS-2236 Fixed bug where manual triggerSnapshot would never finish (#1207)
Posted by wi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
williamsong pushed a commit to branch release-3.1.3
in repository https://gitbox.apache.org/repos/asf/ratis.git
commit 3255448c4abc76c5fea2a5d718056e08ff2c41a3
Author: Potato <ta...@apache.org>
AuthorDate: Thu Jan 9 01:17:10 2025 +0800
RATIS-2236 Fixed bug where manual triggerSnapshot would never finish (#1207)
---
.../main/java/org/apache/ratis/server/impl/StateMachineUpdater.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/ratis-server/src/main/java/org/apache/ratis/server/impl/StateMachineUpdater.java b/ratis-server/src/main/java/org/apache/ratis/server/impl/StateMachineUpdater.java
index c1db1fd3c..a919ca732 100644
--- a/ratis-server/src/main/java/org/apache/ratis/server/impl/StateMachineUpdater.java
+++ b/ratis-server/src/main/java/org/apache/ratis/server/impl/StateMachineUpdater.java
@@ -216,6 +216,9 @@ class StateMachineUpdater implements Runnable {
// Thus it is possible to have applied > committed initially.
final long applied = getLastAppliedIndex();
for(; applied >= raftLog.getLastCommittedIndex() && state == State.RUNNING && !shouldStop(); ) {
+ if (server.getSnapshotRequestHandler().shouldTriggerTakingSnapshot()) {
+ takeSnapshot();
+ }
if (awaitForSignal.await(100, TimeUnit.MILLISECONDS)) {
return;
}
(ratis) 02/02: RATIS-2235. Allow only one thread to perform appendLog (#1206)
Posted by wi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
williamsong pushed a commit to branch release-3.1.3
in repository https://gitbox.apache.org/repos/asf/ratis.git
commit 7a38c998407a1979fe6a96e18e834e8fbb04d011
Author: William Song <48...@users.noreply.github.com>
AuthorDate: Tue Jan 7 02:06:08 2025 +0800
RATIS-2235. Allow only one thread to perform appendLog (#1206)
---
.../java/org/apache/ratis/server/impl/RaftServerImpl.java | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 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 3ffcee079..14b09a023 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
@@ -132,6 +132,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
@@ -249,6 +250,8 @@ class RaftServerImpl implements RaftServer.Division,
private final AtomicBoolean firstElectionSinceStartup = new AtomicBoolean(true);
private final ThreadGroup threadGroup;
+ private final AtomicReference<CompletableFuture<Void>> appendLogFuture;
+
RaftServerImpl(RaftGroup group, StateMachine stateMachine, RaftServerProxy proxy, RaftStorage.StartupOption option)
throws IOException {
final RaftPeerId id = proxy.getId();
@@ -282,6 +285,7 @@ class RaftServerImpl implements RaftServer.Division,
this.transferLeadership = new TransferLeadership(this, properties);
this.snapshotRequestHandler = new SnapshotManagementRequestHandler(this);
this.snapshotInstallationHandler = new SnapshotInstallationHandler(this, properties);
+ this.appendLogFuture = new AtomicReference<>(CompletableFuture.completedFuture(null));
this.serverExecutor = ConcurrentUtils.newThreadPoolWithMax(
RaftServerConfigKeys.ThreadPool.serverCached(properties),
@@ -1585,9 +1589,9 @@ class RaftServerImpl implements RaftServer.Division,
state.updateConfiguration(entries);
}
future.join();
+ final CompletableFuture<Void> appendLog = entries.isEmpty()? CompletableFuture.completedFuture(null)
+ : appendLog(entries);
- final List<CompletableFuture<Long>> futures = entries.isEmpty() ? Collections.emptyList()
- : state.getLog().append(entries);
proto.getCommitInfosList().forEach(commitInfoCache::update);
CodeInjectionForTesting.execute(LOG_SYNC, getId(), null);
@@ -1601,7 +1605,7 @@ class RaftServerImpl implements RaftServer.Division,
final long commitIndex = effectiveCommitIndex(proto.getLeaderCommit(), previous, entries.size());
final long matchIndex = isHeartbeat? RaftLog.INVALID_LOG_INDEX: entries.get(entries.size() - 1).getIndex();
- return JavaUtils.allOf(futures).whenCompleteAsync((r, t) -> {
+ return appendLog.whenCompleteAsync((r, t) -> {
followerState.ifPresent(fs -> fs.updateLastRpcTime(FollowerState.UpdateType.APPEND_COMPLETE));
timer.stop();
}, getServerExecutor()).thenApply(v -> {
@@ -1618,6 +1622,10 @@ class RaftServerImpl implements RaftServer.Division,
return reply;
});
}
+ private CompletableFuture<Void> appendLog(List<LogEntryProto> entries) {
+ return appendLogFuture.updateAndGet(f -> f.thenCompose(
+ ignored -> JavaUtils.allOf(state.getLog().append(entries))));
+ }
private long checkInconsistentAppendEntries(TermIndex previous, List<LogEntryProto> entries) {
// Check if a snapshot installation through state machine is in progress.