Skip to content

Commit

Permalink
[fix](cloud) should do check before abort transaction (apache#40463)
Browse files Browse the repository at this point in the history
When routine load task transaction is abort, it should do check before
abort transaction, otherwise, it may cause concurrent modifications to
the `routineLoadTaskInfoList`, which in the Java language may result in
elements in the list being null, leading to a loop throwing
NullPointerException during scheduling and making it impossible to
schedule routine load task to consume Kafka stream.
  • Loading branch information
sollhui authored and dataroaring committed Sep 9, 2024
1 parent 118c0f4 commit 1d029ff
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,20 @@ public void abortTransaction(Long dbId, Long transactionId, String reason,
TxnCommitAttachment txnCommitAttachment, List<Table> tableList) throws UserException {
LOG.info("try to abort transaction, dbId:{}, transactionId:{}", dbId, transactionId);

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);
}
}
}

AbortTxnRequest.Builder builder = AbortTxnRequest.newBuilder();
builder.setDbId(dbId);
builder.setTxnId(transactionId);
Expand Down

0 comments on commit 1d029ff

Please sign in to comment.