Skip to content

Commit

Permalink
[BugFix] catch TransactionState afterStateTransform exception
Browse files Browse the repository at this point in the history
Signed-off-by: starrocks-xupeng <[email protected]>
  • Loading branch information
starrocks-xupeng committed Feb 10, 2025
1 parent 1e23291 commit b1da74a
Showing 1 changed file with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,11 @@ public VisibleStateWaiter commitTransaction(long transactionId,
txnSpan.setAttribute("num_partition", numPartitions);
unprotectedCommitSpan.end();
// after state transform
transactionState.afterStateTransform(TransactionStatus.COMMITTED, txnOperated, callback, null);
try {
transactionState.afterStateTransform(TransactionStatus.COMMITTED, txnOperated, callback, null);
} catch (Throwable t) {
LOG.warn("transaction after state transform failed: {}", transactionState, t);
}
}

// 6. update nextVersion because of the failure of persistent transaction resulting in error version
Expand Down Expand Up @@ -550,7 +554,11 @@ public void prepareTransaction(long transactionId, List<TabletCommitInfo> tablet
txnSpan.setAttribute("num_partition", numPartitions);
unprotectedCommitSpan.end();
// after state transform
transactionState.afterStateTransform(TransactionStatus.PREPARED, txnOperated, callback, null);
try {
transactionState.afterStateTransform(TransactionStatus.PREPARED, txnOperated, callback, null);
} catch (Throwable t) {
LOG.warn("transaction after state transform failed: {}", transactionState, t);
}
}

LOG.info("transaction:[{}] successfully prepare", transactionState);
Expand Down Expand Up @@ -623,7 +631,11 @@ public VisibleStateWaiter commitPreparedTransaction(long transactionId)
txnSpan.setAttribute("num_partition", numPartitions);
unprotectedCommitSpan.end();
// after state transform
transactionState.afterStateTransform(TransactionStatus.COMMITTED, txnOperated, callback, null);
try {
transactionState.afterStateTransform(TransactionStatus.COMMITTED, txnOperated, callback, null);
} catch (Throwable t) {
LOG.warn("transaction after state transform failed: {}", transactionState, t);
}
}

if (txnOperated) {
Expand Down Expand Up @@ -1105,7 +1117,11 @@ public void finishTransaction(long transactionId, Set<Long> errorReplicaIds) thr
LOG.debug("after set transaction {} to visible", transactionState);
} finally {
writeUnlock();
transactionState.afterStateTransform(TransactionStatus.VISIBLE, txnOperated);
try {
transactionState.afterStateTransform(TransactionStatus.VISIBLE, txnOperated);
} catch (Throwable t) {
LOG.warn("transaction after state transform failed: {}", transactionState, t);
}
}
Span updateCatalogSpan = TraceManager.startSpan("updateCatalogAfterVisible", finishSpan);
try {
Expand Down Expand Up @@ -1390,7 +1406,11 @@ public void abortTransaction(long transactionId, boolean abortPrepared, String r
txnOperated = unprotectAbortTransaction(transactionId, abortPrepared, reason);
} finally {
writeUnlock();
transactionState.afterStateTransform(TransactionStatus.ABORTED, txnOperated, callback, reason);
try {
transactionState.afterStateTransform(TransactionStatus.ABORTED, txnOperated, callback, reason);
} catch (Throwable t) {
LOG.warn("transaction after state transform failed: {}", transactionState, t);
}
}

if (!txnOperated || transactionState.getTransactionStatus() != TransactionStatus.ABORTED) {
Expand Down Expand Up @@ -1827,7 +1847,11 @@ public void finishTransactionNew(TransactionState transactionState, Set<Long> pu
txnOperated = true;
} finally {
writeUnlock();
transactionState.afterStateTransform(TransactionStatus.VISIBLE, txnOperated);
try {
transactionState.afterStateTransform(TransactionStatus.VISIBLE, txnOperated);
} catch (Throwable t) {
LOG.warn("transaction after state transform failed: {}", transactionState, t);
}
}
Span updateCatalogSpan = TraceManager.startSpan("updateCatalogAfterVisible", finishSpan);
try {
Expand Down

0 comments on commit b1da74a

Please sign in to comment.