fix routine load job throw exception after commit (#31303)

This commit is contained in:
HHoflittlefish777
2024-02-23 20:55:44 +08:00
committed by yiguolei
parent db2f0b3574
commit b6ca76e7d4
2 changed files with 10 additions and 1 deletions

View File

@ -1018,6 +1018,16 @@ public abstract class RoutineLoadJob extends AbstractTxnStateChangeCallback impl
// find task in job
Optional<RoutineLoadTaskInfo> routineLoadTaskInfoOptional = routineLoadTaskInfoList.stream().filter(
entity -> entity.getTxnId() == txnState.getTransactionId()).findFirst();
if (!routineLoadTaskInfoOptional.isPresent()) {
// not find task in routineLoadTaskInfoList. this may happen in following case:
// the routine load job has been paused and before transaction committed.
// The routineLoadTaskInfoList will be cleared when job being paused.
// So the task can not be found here.
// This is a normal case, we just print a log here to observe.
LOG.info("Can not find task with transaction {} after committed, job: {}",
txnState.getTransactionId(), id);
return;
}
RoutineLoadTaskInfo routineLoadTaskInfo = routineLoadTaskInfoOptional.get();
taskBeId = routineLoadTaskInfo.getBeId();
executeTaskOnTxnStatusChanged(routineLoadTaskInfo, txnState, TransactionStatus.COMMITTED, null);