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/04/11 08:37:37 UTC
(ignite-3) branch main updated: Ignite-25095 Fix some tech issues of ItTxResourcesVacuumTest. (#5604)
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 9a3e0b35517 Ignite-25095 Fix some tech issues of ItTxResourcesVacuumTest. (#5604)
9a3e0b35517 is described below
commit 9a3e0b35517ca53c22c47effb63d0ab266c5faba
Author: Alexander Lapin <la...@gmail.com>
AuthorDate: Fri Apr 11 11:37:32 2025 +0300
Ignite-25095 Fix some tech issues of ItTxResourcesVacuumTest. (#5604)
---
.../tx/distributed/ItTxResourcesVacuumTest.java | 74 ++++++++++++++++++----
.../internal/tx/test/ItTransactionTestUtils.java | 29 +++++++--
2 files changed, 84 insertions(+), 19 deletions(-)
diff --git a/modules/transactions/src/integrationTest/java/org/apache/ignite/tx/distributed/ItTxResourcesVacuumTest.java b/modules/transactions/src/integrationTest/java/org/apache/ignite/tx/distributed/ItTxResourcesVacuumTest.java
index b03e1eb7c66..5b821508171 100644
--- a/modules/transactions/src/integrationTest/java/org/apache/ignite/tx/distributed/ItTxResourcesVacuumTest.java
+++ b/modules/transactions/src/integrationTest/java/org/apache/ignite/tx/distributed/ItTxResourcesVacuumTest.java
@@ -20,6 +20,7 @@ package org.apache.ignite.tx.distributed;
import static java.util.stream.Collectors.toSet;
import static org.apache.ignite.internal.TestWrappers.unwrapIgniteImpl;
import static org.apache.ignite.internal.catalog.CatalogService.DEFAULT_STORAGE_PROFILE;
+import static org.apache.ignite.internal.lang.IgniteSystemProperties.enabledColocation;
import static org.apache.ignite.internal.sql.engine.util.SqlTestUtils.executeUpdate;
import static org.apache.ignite.internal.table.NodeUtils.transferPrimary;
import static org.apache.ignite.internal.testframework.IgniteTestUtils.runAsync;
@@ -35,6 +36,7 @@ import static org.apache.ignite.internal.tx.test.ItTransactionTestUtils.table;
import static org.apache.ignite.internal.tx.test.ItTransactionTestUtils.tableId;
import static org.apache.ignite.internal.tx.test.ItTransactionTestUtils.txId;
import static org.apache.ignite.internal.tx.test.ItTransactionTestUtils.waitAndGetPrimaryReplica;
+import static org.apache.ignite.internal.tx.test.ItTransactionTestUtils.zoneId;
import static org.apache.ignite.internal.util.IgniteUtils.shutdownAndAwaitTermination;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -59,7 +61,10 @@ import org.apache.ignite.internal.app.IgniteImpl;
import org.apache.ignite.internal.configuration.SystemDistributedConfiguration;
import org.apache.ignite.internal.configuration.SystemDistributedExtensionConfiguration;
import org.apache.ignite.internal.placementdriver.ReplicaMeta;
+import org.apache.ignite.internal.replicator.PartitionGroupId;
import org.apache.ignite.internal.replicator.TablePartitionId;
+import org.apache.ignite.internal.replicator.ZonePartitionId;
+import org.apache.ignite.internal.table.InternalTable;
import org.apache.ignite.internal.testframework.SystemPropertiesExtension;
import org.apache.ignite.internal.testframework.WithSystemProperty;
import org.apache.ignite.internal.thread.IgniteThreadFactory;
@@ -80,6 +85,7 @@ import org.jetbrains.annotations.Nullable;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.api.extension.ExtendWith;
/**
@@ -197,7 +203,13 @@ public class ItTxResourcesVacuumTest extends ClusterPerTestIntegrationTest {
int partId = partitionIdForTuple(node, TABLE_NAME, tuple, tx);
- Set<String> nodes = partitionAssignment(node, new TablePartitionId(tableId(node, TABLE_NAME), partId));
+ Set<String> nodes = partitionAssignment(
+ node,
+ enabledColocation()
+ ? new ZonePartitionId(zoneId(node, TABLE_NAME), partId)
+ : new TablePartitionId(tableId(node, TABLE_NAME), partId)
+ );
+
view.upsert(tx, tuple);
view.upsert(parallelTx1, tupleForParallelTx);
@@ -291,7 +303,9 @@ public class ItTxResourcesVacuumTest extends ClusterPerTestIntegrationTest {
int partId = partitionIdForTuple(anyNode(), TABLE_NAME, tuple, null);
- TablePartitionId groupId = new TablePartitionId(tableId(anyNode(), TABLE_NAME), partId);
+ PartitionGroupId groupId = enabledColocation()
+ ? new ZonePartitionId(zoneId(anyNode(), TABLE_NAME), partId)
+ : new TablePartitionId(tableId(anyNode(), TABLE_NAME), partId);
Set<String> txNodes = partitionAssignment(anyNode(), groupId);
@@ -370,12 +384,19 @@ public class ItTxResourcesVacuumTest extends ClusterPerTestIntegrationTest {
int commitPartId = partitionIdForTuple(node, TABLE_NAME, tuple0, tx);
- TablePartitionId commitPartGrpId = new TablePartitionId(tableId(node, TABLE_NAME), commitPartId);
+ PartitionGroupId commitPartGrpId = enabledColocation()
+ ? new ZonePartitionId(zoneId(node, TABLE_NAME), commitPartId)
+ : new TablePartitionId(tableId(node, TABLE_NAME), commitPartId);
ReplicaMeta replicaMeta = waitAndGetPrimaryReplica(node, commitPartGrpId);
IgniteImpl commitPartitionLeaseholder = findNode(n -> n.id().equals(replicaMeta.getLeaseholderId()));
- Set<String> commitPartNodes = partitionAssignment(node, new TablePartitionId(tableId(node, TABLE_NAME), commitPartId));
+ Set<String> commitPartNodes = partitionAssignment(
+ node,
+ enabledColocation()
+ ? new ZonePartitionId(zoneId(node, TABLE_NAME), commitPartId)
+ : new TablePartitionId(tableId(node, TABLE_NAME), commitPartId)
+ );
log.info("Test: Commit partition [part={}, leaseholder={}, hostingNodes={}].", commitPartGrpId, commitPartitionLeaseholder.name(),
commitPartNodes);
@@ -476,12 +497,19 @@ public class ItTxResourcesVacuumTest extends ClusterPerTestIntegrationTest {
int commitPartId = partitionIdForTuple(node, TABLE_NAME, tuple, tx);
- TablePartitionId commitPartGrpId = new TablePartitionId(tableId(node, TABLE_NAME), commitPartId);
+ PartitionGroupId commitPartGrpId = enabledColocation()
+ ? new ZonePartitionId(zoneId(node, TABLE_NAME), commitPartId)
+ : new TablePartitionId(tableId(node, TABLE_NAME), commitPartId);
ReplicaMeta replicaMeta = waitAndGetPrimaryReplica(node, commitPartGrpId);
IgniteImpl commitPartitionLeaseholder = findNode(n -> n.id().equals(replicaMeta.getLeaseholderId()));
- Set<String> commitPartNodes = partitionAssignment(node, new TablePartitionId(tableId(node, TABLE_NAME), commitPartId));
+ Set<String> commitPartNodes = partitionAssignment(
+ node,
+ enabledColocation()
+ ? new ZonePartitionId(zoneId(node, TABLE_NAME), commitPartId)
+ : new TablePartitionId(tableId(node, TABLE_NAME), commitPartId)
+ );
log.info("Test: Commit partition [leaseholder={}, hostingNodes={}].", commitPartitionLeaseholder.name(), commitPartNodes);
@@ -567,12 +595,19 @@ public class ItTxResourcesVacuumTest extends ClusterPerTestIntegrationTest {
int commitPartId = partitionIdForTuple(node, TABLE_NAME, tuple, tx);
- TablePartitionId commitPartGrpId = new TablePartitionId(tableId(node, TABLE_NAME), commitPartId);
+ PartitionGroupId commitPartGrpId = enabledColocation()
+ ? new ZonePartitionId(zoneId(node, TABLE_NAME), commitPartId)
+ : new TablePartitionId(tableId(node, TABLE_NAME), commitPartId);
ReplicaMeta replicaMeta = waitAndGetPrimaryReplica(node, commitPartGrpId);
IgniteImpl commitPartitionLeaseholder = findNode(n -> n.id().equals(replicaMeta.getLeaseholderId()));
- Set<String> commitPartNodes = partitionAssignment(node, new TablePartitionId(tableId(node, TABLE_NAME), commitPartId));
+ Set<String> commitPartNodes = partitionAssignment(
+ node,
+ enabledColocation()
+ ? new ZonePartitionId(zoneId(node, TABLE_NAME), commitPartId)
+ : new TablePartitionId(tableId(node, TABLE_NAME), commitPartId)
+ );
log.info("Test: Commit partition [part={}, leaseholder={}, hostingNodes={}].", commitPartGrpId, commitPartitionLeaseholder.name(),
commitPartNodes);
@@ -661,8 +696,12 @@ public class ItTxResourcesVacuumTest extends ClusterPerTestIntegrationTest {
int commitPartId = partitionIdForTuple(commitPartitionLeaseholder, TABLE_NAME, tuple0, null);
- Set<String> commitPartitionNodes = partitionAssignment(commitPartitionLeaseholder,
- new TablePartitionId(tableId(commitPartitionLeaseholder, TABLE_NAME), commitPartId));
+ Set<String> commitPartitionNodes = partitionAssignment(
+ commitPartitionLeaseholder,
+ enabledColocation()
+ ? new ZonePartitionId(zoneId(commitPartitionLeaseholder, TABLE_NAME), commitPartId)
+ : new TablePartitionId(tableId(commitPartitionLeaseholder, TABLE_NAME), commitPartId)
+ );
// Choose some node that doesn't host the partition as a tx coordinator.
IgniteImpl coord0 = findNode(n -> !commitPartitionNodes.contains(n.name()));
@@ -737,6 +776,7 @@ public class ItTxResourcesVacuumTest extends ClusterPerTestIntegrationTest {
* </ul>
*/
@Test
+ @Timeout(30)
public void testRoReadTheCorrectDataInBetween() {
IgniteImpl node = anyNode();
@@ -1009,9 +1049,11 @@ public class ItTxResourcesVacuumTest extends ClusterPerTestIntegrationTest {
if (checkCpPrimaryOnly) {
IgniteImpl node = anyNode();
- TablePartitionId tablePartitionId = new TablePartitionId(tableId(node, tableName), partId);
+ PartitionGroupId partitionGroupId = enabledColocation()
+ ? new ZonePartitionId(zoneId(node, tableName), partId)
+ : new TablePartitionId(tableId(node, tableName), partId);
- CompletableFuture<ReplicaMeta> replicaFut = node.placementDriver().getPrimaryReplica(tablePartitionId, node.clock().now());
+ CompletableFuture<ReplicaMeta> replicaFut = node.placementDriver().getPrimaryReplica(partitionGroupId, node.clock().now());
assertThat(replicaFut, willCompleteSuccessfully());
ReplicaMeta replicaMeta = replicaFut.join();
@@ -1079,8 +1121,12 @@ public class ItTxResourcesVacuumTest extends ClusterPerTestIntegrationTest {
@Nullable
private TransactionMeta persistentTxState(IgniteImpl node, UUID txId, String tableName, int partId) {
return runInExecutor(txStateStorageExecutor, () -> {
- TxStatePartitionStorage txStatePartitionStorage = table(node, tableName).internalTable()
- .txStateStorage().getPartitionStorage(partId);
+ InternalTable internalTable = table(node, tableName).internalTable();
+
+ TxStatePartitionStorage txStatePartitionStorage =
+ enabledColocation()
+ ? node.partitionReplicaLifecycleManager().txStatePartitionStorage(internalTable.zoneId(), partId)
+ : internalTable.txStateStorage().getPartitionStorage(partId);
assertNotNull(txStatePartitionStorage);
diff --git a/modules/transactions/src/testFixtures/java/org/apache/ignite/internal/tx/test/ItTransactionTestUtils.java b/modules/transactions/src/testFixtures/java/org/apache/ignite/internal/tx/test/ItTransactionTestUtils.java
index 125ba5a0a7b..9459b4ae4ca 100644
--- a/modules/transactions/src/testFixtures/java/org/apache/ignite/internal/tx/test/ItTransactionTestUtils.java
+++ b/modules/transactions/src/testFixtures/java/org/apache/ignite/internal/tx/test/ItTransactionTestUtils.java
@@ -20,7 +20,7 @@ package org.apache.ignite.internal.tx.test;
import static java.util.Objects.requireNonNull;
import static java.util.concurrent.TimeUnit.SECONDS;
import static java.util.stream.Collectors.toSet;
-import static org.apache.ignite.internal.distributionzones.rebalance.RebalanceUtil.stablePartAssignmentsKey;
+import static org.apache.ignite.internal.lang.IgniteSystemProperties.enabledColocation;
import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -34,14 +34,18 @@ import java.util.function.Consumer;
import java.util.function.Function;
import org.apache.ignite.Ignite;
import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.distributionzones.rebalance.RebalanceUtil;
+import org.apache.ignite.internal.distributionzones.rebalance.ZoneRebalanceUtil;
import org.apache.ignite.internal.lang.ByteArray;
import org.apache.ignite.internal.metastorage.Entry;
import org.apache.ignite.internal.metastorage.MetaStorageManager;
import org.apache.ignite.internal.partitiondistribution.Assignment;
import org.apache.ignite.internal.partitiondistribution.Assignments;
import org.apache.ignite.internal.placementdriver.ReplicaMeta;
+import org.apache.ignite.internal.replicator.PartitionGroupId;
import org.apache.ignite.internal.replicator.ReplicationGroupId;
import org.apache.ignite.internal.replicator.TablePartitionId;
+import org.apache.ignite.internal.replicator.ZonePartitionId;
import org.apache.ignite.internal.schema.BinaryRowEx;
import org.apache.ignite.internal.table.RecordBinaryViewImpl;
import org.apache.ignite.internal.table.TableImpl;
@@ -65,10 +69,13 @@ public class ItTransactionTestUtils {
* @param grpId Group id.
* @return Node names.
*/
- public static Set<String> partitionAssignment(IgniteImpl node, TablePartitionId grpId) {
+ public static Set<String> partitionAssignment(IgniteImpl node, PartitionGroupId grpId) {
MetaStorageManager metaStorageManager = node.metaStorageManager();
- ByteArray stableAssignmentKey = stablePartAssignmentsKey(grpId);
+ ByteArray stableAssignmentKey =
+ enabledColocation()
+ ? ZoneRebalanceUtil.stablePartAssignmentsKey((ZonePartitionId) grpId)
+ : RebalanceUtil.stablePartAssignmentsKey((TablePartitionId) grpId);
CompletableFuture<Entry> assignmentEntryFut = metaStorageManager.get(stableAssignmentKey);
@@ -125,7 +132,6 @@ public class ItTransactionTestUtils {
boolean primary
) {
Tuple t = initialTuple;
- int tableId = tableId(node, tableName);
Set<Integer> partitionIds = new HashSet<>();
Set<String> nodes = new HashSet<>();
@@ -137,7 +143,9 @@ public class ItTransactionTestUtils {
int partId = partitionIdForTuple(node, tableName, t, tx);
partitionIds.add(partId);
- TablePartitionId grpId = new TablePartitionId(tableId, partId);
+ PartitionGroupId grpId = enabledColocation()
+ ? new ZonePartitionId(zoneId(node, tableName), partId)
+ : new TablePartitionId(tableId(node, tableName), partId);
if (primary) {
ReplicaMeta replicaMeta = waitAndGetPrimaryReplica(node, grpId);
@@ -188,6 +196,17 @@ public class ItTransactionTestUtils {
return table(node, tableName).tableId();
}
+ /**
+ * Returns the zone id.
+ *
+ * @param node Any node in the cluster.
+ * @param tableName Table name.
+ * @return Zone id.
+ */
+ public static int zoneId(Ignite node, String tableName) {
+ return table(node, tableName).zoneId();
+ }
+
/**
* Transaction id.
*