This is an automated email from the ASF dual-hosted git repository. ibessonov 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 0e0ba6a3ca IGNITE-20180 Fix flaky ItTablePersistenceTest#testSnapshot (#2428) 0e0ba6a3ca is described below commit 0e0ba6a3ca8e4432e642be75b8d27ea23ceaa0e0 Author: Ivan Bessonov <bessonov...@gmail.com> AuthorDate: Thu Aug 10 11:31:57 2023 +0300 IGNITE-20180 Fix flaky ItTablePersistenceTest#testSnapshot (#2428) --- .../raft/service/ItAbstractListenerSnapshotTest.java | 7 +++++++ .../ignite/distributed/ItTablePersistenceTest.java | 17 ++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/modules/raft/src/testFixtures/java/org/apache/ignite/internal/raft/service/ItAbstractListenerSnapshotTest.java b/modules/raft/src/testFixtures/java/org/apache/ignite/internal/raft/service/ItAbstractListenerSnapshotTest.java index fce4690e24..ec6ce84fbb 100644 --- a/modules/raft/src/testFixtures/java/org/apache/ignite/internal/raft/service/ItAbstractListenerSnapshotTest.java +++ b/modules/raft/src/testFixtures/java/org/apache/ignite/internal/raft/service/ItAbstractListenerSnapshotTest.java @@ -145,6 +145,13 @@ public abstract class ItAbstractListenerSnapshotTest<T extends RaftGroupListener return 3; } + /** + * Returns a list of started servers. + */ + protected List<JraftServerImpl> servers() { + return List.copyOf(servers); + } + /** * Test parameters for {@link #testSnapshot}. */ diff --git a/modules/table/src/integrationTest/java/org/apache/ignite/distributed/ItTablePersistenceTest.java b/modules/table/src/integrationTest/java/org/apache/ignite/distributed/ItTablePersistenceTest.java index a49467a756..28c7b6339e 100644 --- a/modules/table/src/integrationTest/java/org/apache/ignite/distributed/ItTablePersistenceTest.java +++ b/modules/table/src/integrationTest/java/org/apache/ignite/distributed/ItTablePersistenceTest.java @@ -33,6 +33,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMaps; import java.nio.file.Path; import java.util.HashMap; import java.util.LinkedList; +import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; @@ -225,7 +226,21 @@ public class ItTablePersistenceTest extends ItAbstractListenerSnapshotTest<Parti ReadWriteSingleRowReplicaRequest req0 = (ReadWriteSingleRowReplicaRequest) req; if (req0.requestType() == RequestType.RW_GET) { - int storageIndex = stoppedNodeIndex == 0 ? 1 : 0; + List<JraftServerImpl> servers = servers(); + + JraftServerImpl leader = servers.stream() + .filter(server -> server.localPeers(raftGroupId()).contains(service.leader())) + .findFirst().orElseThrow(); + + // We only read from the leader, every other node may not have the latest data. + int storageIndex = servers.indexOf(leader); + + // Here we must account for the stopped node, index in "servers" and index in "mvPartitionStorages" will differ + // for "serverIndex >= stoppedNodeIndex". + if (storageIndex >= stoppedNodeIndex) { + storageIndex++; + } + MvPartitionStorage partitionStorage = mvPartitionStorages.get(storageIndex); Map<BinaryRow, RowId> primaryIndex = rowsToRowIds(partitionStorage);