This is an automated email from the ASF dual-hosted git repository. sk0x50 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 1f61771f70 IGNITE-17770 Fix ItIgniteNodeRestartTest.testCfgGap (#2224) 1f61771f70 is described below commit 1f61771f709a2c9cad60bf91706e013c396e4137 Author: Denis Chudov <moongll...@gmail.com> AuthorDate: Wed Jun 28 15:57:51 2023 +0300 IGNITE-17770 Fix ItIgniteNodeRestartTest.testCfgGap (#2224) --- .../runner/app/ItIgniteNodeRestartTest.java | 24 ++++++++++++++++++---- .../distributed/storage/InternalTableImpl.java | 18 ++++++++++++---- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteNodeRestartTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteNodeRestartTest.java index 08b11f42ed..f57fae0c9e 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteNodeRestartTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteNodeRestartTest.java @@ -135,6 +135,7 @@ import org.apache.ignite.sql.SqlRow; import org.apache.ignite.table.Table; import org.apache.ignite.table.Tuple; import org.apache.ignite.tx.TransactionException; +import org.awaitility.Awaitility; import org.intellij.lang.annotations.Language; import org.jetbrains.annotations.Nullable; import org.junit.jupiter.api.Disabled; @@ -1092,7 +1093,6 @@ public class ItIgniteNodeRestartTest extends BaseIgniteRestartTest { * The test for node restart when there is a gap between the node local configuration and distributed configuration. */ @Test - @Disabled("https://issues.apache.org/jira/browse/IGNITE-17770") public void testCfgGap() throws InterruptedException { List<IgniteImpl> nodes = startNodes(4); @@ -1150,9 +1150,25 @@ public class ItIgniteNodeRestartTest extends BaseIgniteRestartTest { assertNotNull(table); for (int i = 0; i < 100; i++) { - Tuple row = table.keyValueView().get(null, Tuple.create().set("id", i)); - - assertEquals(VALUE_PRODUCER.apply(i), row.stringValue("name")); + int fi = i; + + Awaitility.with() + .await() + .pollInterval(100, TimeUnit.MILLISECONDS) + .pollDelay(0, TimeUnit.MILLISECONDS) + .atMost(30, TimeUnit.SECONDS) + .until(() -> { + try { + Tuple row = table.keyValueView().get(null, Tuple.create().set("id", fi)); + + assertEquals(VALUE_PRODUCER.apply(fi), row.stringValue("name")); + + return true; + } catch (TransactionException te) { + // There may be an exception if the primary replica node was stopped. We should wait for new primary to appear. + return false; + } + }); } } diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java index 98fc9148c4..d50e41233c 100644 --- a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java +++ b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java @@ -450,11 +450,13 @@ public class InternalTableImpl implements InternalTable { throw new TransactionException(e); } catch (Throwable e) { throw new TransactionException( + INTERNAL_ERR, IgniteStringFormatter.format( - "Failed to enlist partition[tableName={}, partId={}] into a transaction", + "Failed to enlist partition [tableName={}, partId={}] into a transaction", tableName, partId - ) + ), + e ); } }) @@ -1315,10 +1317,18 @@ public class InternalTableImpl implements InternalTable { throw new TransactionException(REPLICA_UNAVAILABLE_ERR, "Failed to get the primary replica."); } + String consistentId = primaryPeerAndTerm.leader().consistentId(); + + ClusterNode node = clusterNodeResolver.apply(consistentId); + + if (node == null) { + throw new TransactionException(REPLICA_UNAVAILABLE_ERR, "Failed to resolve the primary replica node [consistentId=" + + consistentId + ']'); + } + TablePartitionId partGroupId = new TablePartitionId(tableId, partId); - return tx.enlist(partGroupId, - new IgniteBiTuple<>(clusterNodeResolver.apply(primaryPeerAndTerm.leader().consistentId()), primaryPeerAndTerm.term())); + return tx.enlist(partGroupId, new IgniteBiTuple<>(node, primaryPeerAndTerm.term())); }); }