You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sa...@apache.org on 2025/05/05 17:28:15 UTC
(ignite-3) branch main updated: IGNITE-24111 Prevent onLeaderElected event duplication within TopologyAwareRaftGroupService (#5724)
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 c281c8cc21c IGNITE-24111 Prevent onLeaderElected event duplication within TopologyAwareRaftGroupService (#5724)
c281c8cc21c is described below
commit c281c8cc21c26514c367942e8abfd13de04524a4
Author: Alexander Lapin <la...@gmail.com>
AuthorDate: Mon May 5 20:28:11 2025 +0300
IGNITE-24111 Prevent onLeaderElected event duplication within TopologyAwareRaftGroupService (#5724)
---
.../internal/raft/client/TopologyAwareRaftGroupService.java | 5 ++++-
.../raft/client/AbstractTopologyAwareGroupServiceTest.java | 10 ++++++++++
.../ItHighAvailablePartitionsRecoveryByFilterUpdateTest.java | 8 ++++----
.../disaster/ItHighAvailablePartitionsRecoveryTest.java | 4 ++--
.../disaster/ItDisasterRecoveryReconfigurationTest.java | 2 +-
5 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/modules/replicator/src/main/java/org/apache/ignite/internal/raft/client/TopologyAwareRaftGroupService.java b/modules/replicator/src/main/java/org/apache/ignite/internal/raft/client/TopologyAwareRaftGroupService.java
index 759561d326f..218f99dbb6f 100644
--- a/modules/replicator/src/main/java/org/apache/ignite/internal/raft/client/TopologyAwareRaftGroupService.java
+++ b/modules/replicator/src/main/java/org/apache/ignite/internal/raft/client/TopologyAwareRaftGroupService.java
@@ -321,7 +321,10 @@ public class TopologyAwareRaftGroupService implements RaftGroupService {
public CompletableFuture<Void> subscribeLeader(LeaderElectionListener callback) {
// TODO: https://issues.apache.org/jira/browse/IGNITE-23863 do the refactoring to make the code more consistent.
if (serverEventHandler.isSubscribed()) {
- eventsClientListener.addLeaderElectionListener(groupId(), callback);
+ ServerEventHandler wrappedEventHandler = new ServerEventHandler();
+ wrappedEventHandler.setOnLeaderElectedCallback(callback);
+
+ eventsClientListener.addLeaderElectionListener(groupId(), wrappedEventHandler);
} else {
serverEventHandler.setOnLeaderElectedCallback(callback);
}
diff --git a/modules/replicator/src/testFixtures/java/org/apache/ignite/internal/raft/client/AbstractTopologyAwareGroupServiceTest.java b/modules/replicator/src/testFixtures/java/org/apache/ignite/internal/raft/client/AbstractTopologyAwareGroupServiceTest.java
index c3ba909b984..4b753e0eb23 100644
--- a/modules/replicator/src/testFixtures/java/org/apache/ignite/internal/raft/client/AbstractTopologyAwareGroupServiceTest.java
+++ b/modules/replicator/src/testFixtures/java/org/apache/ignite/internal/raft/client/AbstractTopologyAwareGroupServiceTest.java
@@ -181,6 +181,16 @@ public abstract class AbstractTopologyAwareGroupServiceTest extends IgniteAbstra
assertNotNull(leader);
afterClusterInit(leader.name());
+
+ // Below we check that leaderElectionCallback is called once only.
+ AtomicInteger leaderElectionCallbackCallsCounter = new AtomicInteger(0);
+ raftClient.subscribeLeader((leader0, term) -> leaderElectionCallbackCallsCounter.incrementAndGet());
+
+ // Leader election callback triggering is asynchronous, thus it's required to give it some time to be called. With 1 second await
+ // interval the test will fail 100/100 if there's no fix.
+ Thread.sleep(1_000);
+
+ assertEquals(1, leaderElectionCallbackCallsCounter.get());
}
/**
diff --git a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/distributed/disaster/ItHighAvailablePartitionsRecoveryByFilterUpdateTest.java b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/distributed/disaster/ItHighAvailablePartitionsRecoveryByFilterUpdateTest.java
index 13b03030b0a..c6c05e6ce55 100644
--- a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/distributed/disaster/ItHighAvailablePartitionsRecoveryByFilterUpdateTest.java
+++ b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/distributed/disaster/ItHighAvailablePartitionsRecoveryByFilterUpdateTest.java
@@ -63,7 +63,7 @@ public class ItHighAvailablePartitionsRecoveryByFilterUpdateTest extends Abstrac
}
@Test
- @Disabled("https://issues.apache.org/jira/browse/IGNITE-24111")
+ @Disabled("https://issues.apache.org/jira/browse/IGNITE-25285")
void testScaleUpAfterZoneFilterUpdate() throws InterruptedException {
startNode(1, EU_ONLY_NODES_CONFIG);
startNode(2, EU_ONLY_NODES_CONFIG);
@@ -119,7 +119,7 @@ public class ItHighAvailablePartitionsRecoveryByFilterUpdateTest extends Abstrac
}
@Test
- @Disabled("https://issues.apache.org/jira/browse/IGNITE-24111")
+ @Disabled("https://issues.apache.org/jira/browse/IGNITE-25285")
void testThatPartitionResetZoneStorageProfileFilterAware() throws InterruptedException {
startNode(1, AIPERSIST_NODES_CONFIG);
startNode(2, ROCKS_NODES_CONFIG);
@@ -223,7 +223,7 @@ public class ItHighAvailablePartitionsRecoveryByFilterUpdateTest extends Abstrac
* @throws Exception If failed.
*/
@Test
- @Disabled("https://issues.apache.org/jira/browse/IGNITE-24111")
+ @Disabled("https://issues.apache.org/jira/browse/IGNITE-25285")
void testNodesWaitForLastNodeFromChainToComeBackOnlineAfterMajorityStops() throws Exception {
for (int i = 1; i < 8; i++) {
startNode(i, CUSTOM_NODES_CONFIG);
@@ -284,7 +284,7 @@ public class ItHighAvailablePartitionsRecoveryByFilterUpdateTest extends Abstrac
* @throws Exception If failed.
*/
@Test
- @Disabled("https://issues.apache.org/jira/browse/IGNITE-24111")
+ @Disabled("https://issues.apache.org/jira/browse/IGNITE-25285")
void testNodesWaitForNodesFromGracefulChainToComeBackOnlineAfterMajorityStops() throws Exception {
for (int i = 1; i < 8; i++) {
startNode(i, CUSTOM_NODES_CONFIG);
diff --git a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/distributed/disaster/ItHighAvailablePartitionsRecoveryTest.java b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/distributed/disaster/ItHighAvailablePartitionsRecoveryTest.java
index fbeaf3af071..2664386a940 100644
--- a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/distributed/disaster/ItHighAvailablePartitionsRecoveryTest.java
+++ b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/distributed/disaster/ItHighAvailablePartitionsRecoveryTest.java
@@ -391,7 +391,7 @@ public class ItHighAvailablePartitionsRecoveryTest extends AbstractHighAvailable
* </ol>
*/
@Test
- @Disabled("https://issues.apache.org/jira/browse/IGNITE-24111")
+ @Disabled("https://issues.apache.org/jira/browse/IGNITE-25285")
void testManualRecovery() throws InterruptedException {
startNode(3);
startNode(4);
@@ -494,7 +494,7 @@ public class ItHighAvailablePartitionsRecoveryTest extends AbstractHighAvailable
* @throws Exception If failed.
*/
@Test
- @Disabled("https://issues.apache.org/jira/browse/IGNITE-24111")
+ @Disabled("https://issues.apache.org/jira/browse/IGNITE-25285")
void testNodeStateCleanupAfterRestartInHaMode() throws Exception {
startNode(3);
startNode(4);
diff --git a/modules/transactions/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryReconfigurationTest.java b/modules/transactions/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryReconfigurationTest.java
index 35e23ebfe4c..7af2c71966a 100644
--- a/modules/transactions/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryReconfigurationTest.java
+++ b/modules/transactions/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryReconfigurationTest.java
@@ -1496,7 +1496,7 @@ public class ItDisasterRecoveryReconfigurationTest extends ClusterPerTestIntegra
assertAssignmentsChain(node0, partId, AssignmentsChain.of(allAssignments, link2Assignments, link3Assignments));
}
- @Disabled("https://issues.apache.org/jira/browse/IGNITE-24111")
+ @Disabled("https://issues.apache.org/jira/browse/IGNITE-25285")
@Test
@ZoneParams(nodes = 7, replicas = 7, partitions = 1, consistencyMode = ConsistencyMode.HIGH_AVAILABILITY)
void testSecondResetRewritesUnfinishedFirstPhaseReset() throws Exception {