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 09cd1d897d IGNITE-22042 Do not enlist operations in a FINISHING
transaction (#3604)
09cd1d897d is described below
commit 09cd1d897d0ee56220dfab807d0cb5db4aa266d1
Author: Cyrill <[email protected]>
AuthorDate: Tue Apr 16 14:25:54 2024 +0300
IGNITE-22042 Do not enlist operations in a FINISHING transaction (#3604)
---
.../replicator/PartitionReplicaListener.java | 2 +-
.../replication/PartitionReplicaListenerTest.java | 23 ++++++++++++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
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 f8a9090320..45ced734e9 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
@@ -1999,7 +1999,7 @@ public class PartitionReplicaListener implements
ReplicaListener {
// And complete cleanupReadyFut with exception if it is the case.
TxStateMeta txStateMeta = txManager.stateMeta(txId);
- if (txStateMeta == null || isFinalState(txStateMeta.txState())) {
+ if (txStateMeta == null || isFinalState(txStateMeta.txState()) ||
txStateMeta.txState() == FINISHING) {
cleanupReadyFut.completeExceptionally(new Exception());
return txOps;
diff --git
a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerTest.java
b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerTest.java
index 2be41d90b1..781b019e16 100644
---
a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerTest.java
+++
b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerTest.java
@@ -36,6 +36,7 @@ import static
org.apache.ignite.internal.testframework.matchers.CompletableFutur
import static org.apache.ignite.internal.tx.TransactionIds.beginTimestamp;
import static org.apache.ignite.internal.tx.TxState.ABORTED;
import static org.apache.ignite.internal.tx.TxState.COMMITTED;
+import static org.apache.ignite.internal.tx.TxState.FINISHING;
import static org.apache.ignite.internal.tx.TxState.checkTransitionCorrectness;
import static org.apache.ignite.internal.util.ArrayUtils.asList;
import static
org.apache.ignite.internal.util.CompletableFutures.nullCompletedFuture;
@@ -704,6 +705,22 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
assertTrue(readTimestamp.compareTo(txMeta.commitTimestamp()) > 0);
}
+ @CartesianTest
+ @CartesianTest.MethodFactory("finishedTxTypesFactory")
+ void testExecuteRequestOnFinishedTx(TxState txState, RequestType
requestType) {
+ UUID txId = newTxId();
+
+ txStateStorage.put(txId, new TxMeta(txState, singletonList(grpId),
null));
+ txManager.updateTxMeta(txId, old -> new TxStateMeta(txState, null,
null, null));
+
+ BinaryRow testRow = binaryRow(0);
+
+ assertThat(
+ doSingleRowRequest(txId, testRow, requestType),
+ willThrowFast(TransactionException.class, "Transaction is
already finished")
+ );
+ }
+
@Test
public void
testEnsureReplicaIsPrimaryThrowsPrimaryReplicaMissIfEnlistmentConsistencyTokenDoesNotMatchTheOneInLease()
{
localLeader = false;
@@ -2141,6 +2158,12 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
.argumentsForNextParameter(false, true);
}
+ @SuppressWarnings("unused")
+ private static ArgumentSets finishedTxTypesFactory() {
+ return ArgumentSets.argumentsForFirstParameter(FINISHING, ABORTED,
COMMITTED)
+ .argumentsForNextParameter(singleRowRwOperationTypes());
+ }
+
private static Stream<RequestType> singleRowRwOperationTypes() {
return Arrays.stream(RequestType.values())
.filter(RequestTypes::isSingleRowRw);