This is an automated email from the ASF dual-hosted git repository.
sanpwc pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new 08762446b5 IGNITE-23238 Prevent closure state reinitialization (#4429)
08762446b5 is described below
commit 08762446b58b9b28f4dae3d9ec984910e5d1e200
Author: Alexander Lapin <[email protected]>
AuthorDate: Mon Sep 23 16:01:20 2024 +0300
IGNITE-23238 Prevent closure state reinitialization (#4429)
---
.../java/org/apache/ignite/raft/jraft/core/ItNodeTest.java | 5 ++++-
.../src/main/java/org/apache/ignite/raft/jraft/core/NodeImpl.java | 8 ++++++--
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git
a/modules/raft/src/integrationTest/java/org/apache/ignite/raft/jraft/core/ItNodeTest.java
b/modules/raft/src/integrationTest/java/org/apache/ignite/raft/jraft/core/ItNodeTest.java
index 1189b04328..3dfe7d59b7 100644
---
a/modules/raft/src/integrationTest/java/org/apache/ignite/raft/jraft/core/ItNodeTest.java
+++
b/modules/raft/src/integrationTest/java/org/apache/ignite/raft/jraft/core/ItNodeTest.java
@@ -3097,10 +3097,13 @@ public class ItNodeTest extends BaseIgniteAbstractTest {
leader.changePeersAndLearnersAsync(new
Configuration(Collections.singletonList(newPeer)),
leader.getCurrentTerm(), done);
- assertEquals(done.await(), Status.OK());
+ assertEquals(Status.OK(), done.await());
verify(raftGrpEvtsLsnr, timeout(10_000))
.onReconfigurationError(argThat(st -> st.getRaftError() ==
RaftError.ECATCHUP), any(), any(), anyLong());
+
+ // Verify that initial close state wasn't reinitialized.
+ assertEquals(Status.OK(), done.await());
}
@Test
diff --git
a/modules/raft/src/main/java/org/apache/ignite/raft/jraft/core/NodeImpl.java
b/modules/raft/src/main/java/org/apache/ignite/raft/jraft/core/NodeImpl.java
index 4b7fb58408..618a481aac 100644
--- a/modules/raft/src/main/java/org/apache/ignite/raft/jraft/core/NodeImpl.java
+++ b/modules/raft/src/main/java/org/apache/ignite/raft/jraft/core/NodeImpl.java
@@ -334,6 +334,7 @@ public class NodeImpl implements Node, RaftServerService {
List<PeerId> newLearners = new ArrayList<>();
List<PeerId> oldLearners = new ArrayList<>();
Closure done;
+ boolean async;
ConfigurationCtx(final NodeImpl node) {
super();
@@ -361,6 +362,7 @@ public class NodeImpl implements Node, RaftServerService {
}
this.done = done;
this.stage = Stage.STAGE_CATCHING_UP;
+ this.async = async;
if (async) {
Utils.runClosureInThread(this.node.getOptions().getCommonExecutor(), done,
Status.OK());
}
@@ -473,10 +475,12 @@ public class NodeImpl implements Node, RaftServerService {
}
}
- oldDoneClosure.run(status);
+ if (!this.async) {
+ oldDoneClosure.run(status);
+ }
};
- // TODO: in case of changePeerAsync this invocation is useless
as far as we have already sent OK response in done closure.
+ // In case of changePeerAsync this invocation is used in order
to trigger listener callbacks.
Utils.runClosureInThread(this.node.getOptions().getCommonExecutor(), newDone,
st != null ? st : LEADER_STEPPED_DOWN);
this.done = null;
}