This is an automated email from the ASF dual-hosted git repository. vpyatkov pushed a commit to branch ignite-20918 in repository https://gitbox.apache.org/repos/asf/ignite-3.git
commit 56277f7c92327513933aa0d76651aa1954478cee Author: Vladislav Pyatkov <[email protected]> AuthorDate: Thu Nov 23 13:59:11 2023 +0300 WIP --- .../table/distributed/replicator/PartitionReplicaListener.java | 8 ++++---- .../replication/PartitionReplicaListenerIndexLockingTest.java | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java index 07abb1c326..92958eaa14 100644 --- a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java +++ b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java @@ -343,7 +343,7 @@ public class PartitionReplicaListener implements ReplicaListener { } private CompletableFuture<Boolean> onPrimaryElected(PrimaryReplicaEventParameters evt, @Nullable Throwable exception) { - if (!localNode.name().equals(evt.leaseholder())) { + if (!localNode.name().equals(evt.leaseholder()) || !replicationGroupId.equals(evt.groupId())) { return completedFuture(false); } @@ -3386,9 +3386,9 @@ public class PartitionReplicaListener implements ReplicaListener { long currentEnlistmentConsistencyToken = primaryReplicaMeta.getStartTime().longValue(); // TODO: https://issues.apache.org/jira/browse/IGNITE-20377 - if (expectedTerm != currentEnlistmentConsistencyToken || - primaryReplicaMeta.getExpirationTime().before(now) || - !primaryReplicaMeta.getLeaseholderId().equals(localNode.id())) { + if (expectedTerm != currentEnlistmentConsistencyToken + || primaryReplicaMeta.getExpirationTime().before(now) + || !primaryReplicaMeta.getLeaseholderId().equals(localNode.id())) { return failedFuture(new PrimaryReplicaMissException( localNode.name(), primaryReplicaMeta.getLeaseholder(), diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerIndexLockingTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerIndexLockingTest.java index 95be4b2e27..f7974d1cc0 100644 --- a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerIndexLockingTest.java +++ b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerIndexLockingTest.java @@ -102,6 +102,8 @@ import org.apache.ignite.internal.util.Lazy; import org.apache.ignite.internal.util.Pair; import org.apache.ignite.internal.util.PendingComparableValuesTracker; import org.apache.ignite.network.ClusterNode; +import org.apache.ignite.network.ClusterNodeImpl; +import org.apache.ignite.network.NetworkAddress; import org.hamcrest.CustomMatcher; import org.hamcrest.Matcher; import org.junit.jupiter.api.BeforeAll; @@ -203,7 +205,7 @@ public class PartitionReplicaListenerIndexLockingTest extends IgniteAbstractTest when(catalogService.table(anyInt(), anyLong())).thenReturn(tableDescriptor); - ClusterNode localNode = mock(ClusterNode.class); + ClusterNode localNode = new ClusterNodeImpl("test-node-id", "test-node", new NetworkAddress("localhost", 1234)); partitionReplicaListener = new PartitionReplicaListener( TEST_MV_PARTITION_STORAGE,
