This is an automated email from the ASF dual-hosted git repository.
szetszwo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ratis.git
The following commit(s) were added to refs/heads/master by this push:
new 43c4e00b8 RATIS-761. Handle writeStateMachineData failure in leader.
(#927)
43c4e00b8 is described below
commit 43c4e00b8e960079dc2cb86fbaba516cfa60df18
Author: Tsz-Wo Nicholas Sze <[email protected]>
AuthorDate: Tue Oct 10 12:46:18 2023 -0700
RATIS-761. Handle writeStateMachineData failure in leader. (#927)
---
.../org/apache/ratis/server/raftlog/RaftLogBase.java | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git
a/ratis-server/src/main/java/org/apache/ratis/server/raftlog/RaftLogBase.java
b/ratis-server/src/main/java/org/apache/ratis/server/raftlog/RaftLogBase.java
index 579d62cf5..31865038e 100644
---
a/ratis-server/src/main/java/org/apache/ratis/server/raftlog/RaftLogBase.java
+++
b/ratis-server/src/main/java/org/apache/ratis/server/raftlog/RaftLogBase.java
@@ -185,7 +185,22 @@ public abstract class RaftLogBase implements RaftLog {
throw new StateMachineException(memberId, new RaftLogIOException(
"Log entry size " + entrySize + " exceeds the max buffer limit of
" + maxBufferSize));
}
- appendEntry(e);
+ appendEntry(e).whenComplete((returned, t) -> {
+ if (t != null) {
+ LOG.error(name + ": Failed to write log entry " +
LogProtoUtils.toLogEntryString(e), t);
+ } else if (returned != nextIndex) {
+ LOG.error("{}: Indices mismatched: returned index={} but
nextIndex={} for log entry {}",
+ name, returned, nextIndex, LogProtoUtils.toLogEntryString(e));
+ } else {
+ return; // no error
+ }
+
+ try {
+ close(); // close due to error
+ } catch (IOException ioe) {
+ LOG.error("Failed to close " + name, ioe);
+ }
+ });
return nextIndex;
}
}