sanpwc commented on code in PR #2751:
URL: https://github.com/apache/ignite-3/pull/2751#discussion_r1382917995
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java:
##########
@@ -1437,6 +1450,47 @@ private CompletableFuture<Void> finishAndCleanup(
UUID txId,
String txCoordinatorId
) {
+ TxMeta txMeta = txStateStorage.get(txId);
+
+ // Check that a transaction has already been finished.
+ boolean transactionAlreadyFinished = txMeta != null &&
isFinalState(txMeta.txState());
+
+ // Check locksReleased flag. If it is already set, do nothing and
return a successful result.
+ // Even if the outcome is different (the transaction was aborted, but
we want to commit it),
+ // we return 'success' to be in alignment with common transaction
handling.
+ if (transactionAlreadyFinished) {
+ if (txMeta.locksReleased()) {
+ return completedFuture(null);
+ }
+ // If the locks were not released, we are likely to be in a
recovery mode and retrying the finish request.
+ // In this case we want to check the expected outcome and the
actual one.
+ if (commit && txMeta.txState() == ABORTED) {
+ LOG.error("Failed to commit a transaction that is already
aborted [txId={}].", txId);
+
+ throw new TransactionException(TX_WAS_ABORTED_ERR,
+ "Failed to change the outcome of a finished
transaction"
+ + " [txId=" + txId + ", txState=" +
txMeta.txState() + "].");
+ }
+ // The transaction has already been finished, but the locks are
not released.
+ // Waiting for the cleanup to do this.
+ // TODO: There is a risk that nobody is cleaning up this
transaction.
Review Comment:
Let's discuss the question. Generally speaking it should not be part of tx
coordinator recovery but a commit partition one that should be already
implemented. What I mean here is that, when tx state is updated to either
committed or aborted tx coordinator should believe that his work is done and
commit partition itself should retry cleanup until locks release.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]