github-actions[bot] commented on code in PR #61881:
URL: https://github.com/apache/doris/pull/61881#discussion_r3052429700
##########
fe/fe-core/src/main/java/org/apache/doris/cloud/transaction/CloudGlobalTransactionMgr.java:
##########
@@ -1803,29 +1804,60 @@ public void abortTransaction(Long dbId, Long
transactionId, String reason) throw
@Override
public void abortTransaction(Long dbId, Long transactionId, String reason,
TxnCommitAttachment txnCommitAttachment, List<Table> tableList)
throws UserException {
- if (txnCommitAttachment != null) {
- if (txnCommitAttachment instanceof RLTaskTxnCommitAttachment) {
- RLTaskTxnCommitAttachment rlTaskTxnCommitAttachment =
(RLTaskTxnCommitAttachment) txnCommitAttachment;
- TxnStateChangeCallback cb =
callbackFactory.getCallback(rlTaskTxnCommitAttachment.getJobId());
- if (cb != null) {
- // use a temporary transaction state to do before commit
check,
- // what actually works is the transactionId
- TransactionState tmpTxnState = new TransactionState();
- tmpTxnState.setTransactionId(transactionId);
- cb.beforeAborted(tmpTxnState);
- }
- }
- }
+ Pair<Long, TxnStateChangeCallback> callbackInfo =
+ handleBeforeAbort(dbId, transactionId, txnCommitAttachment);
AbortTxnResponse abortTxnResponse = null;
try {
abortTxnResponse = abortTransactionImpl(dbId, transactionId,
reason, null);
} finally {
- handleAfterAbort(abortTxnResponse, txnCommitAttachment,
transactionId);
+ handleAfterAbort(abortTxnResponse, txnCommitAttachment,
transactionId,
+ callbackInfo.first, callbackInfo.second);
clearTxnLastSignature(dbId, transactionId);
}
}
+ /**
+ * Resolves the transaction callback and calls beforeAborted() before the
abort RPC,
+ * so the lock-handoff pattern (beforeAborted acquires, afterAborted
releases) wraps
+ * the correct scope.
+ *
+ * @return a Pair of (callbackId, callback); callback is null if no
callback is registered
+ * or if beforeAborted failed (in either case handleAfterAbort
will skip afterAborted)
+ */
+ private Pair<Long, TxnStateChangeCallback> handleBeforeAbort(Long dbId,
long transactionId,
+ TxnCommitAttachment txnCommitAttachment) {
+ long callbackId = 0L;
+ if (txnCommitAttachment instanceof RLTaskTxnCommitAttachment) {
+ callbackId = ((RLTaskTxnCommitAttachment)
txnCommitAttachment).getJobId();
+ } else if (txnCommitAttachment == null) {
+ // txnCommitAttachment is null (e.g. BE restart abort): the
callbackId is only
Review Comment:
`handleAfterAbort()` no longer reconstructs the callback from
`abortTxnResponse.getTxnInfo().getCallbackId()`, so this code now makes the
entire abort callback flow depend on the pre-query succeeding here.
`getTransactionState()` returns `null` on `RpcException` and on any non-OK /
missing-`txnInfo` response, but `abortTransactionImpl()` has its own RPC call +
retry loop and can still successfully abort the txn afterwards. In that case
the abort response still contains the real callback id, yet `callbackId` is
still `0` here, `cb` stays `null`, and `afterAborted()` is skipped entirely.
For routine load that means the successful abort never clears `runningTxnIds` /
renews task state, so the job can stall again after exactly the kind of
transient MetaService failure this path should tolerate. Please preserve the
new `beforeAborted()` prefetch, but also fall back to
`txnState.getCallbackId()` from `abortTxnResponse` when the pre-query did not
resolve a callback.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]