This is an automated email from the ASF dual-hosted git repository.

diwu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 8548d7b86c8 [fix](streaming-job) Fix NPE in 
StreamingInsertJob.replayOnCommitted during EditLog replay (#62416)
8548d7b86c8 is described below

commit 8548d7b86c8c499a7e885ebcc7175ad3bf78e38b
Author: wudi <[email protected]>
AuthorDate: Wed Apr 15 14:31:17 2026 +0800

    [fix](streaming-job) Fix NPE in StreamingInsertJob.replayOnCommitted during 
EditLog replay (#62416)
    
    ### What problem does this PR solve?
    
    Problem Summary:
    
    Fix NPE in `StreamingInsertJob.replayOnCommitted()` during FE checkpoint
    EditLog replay.
    
    When a streaming insert task is canceled while its transaction is being
    committed, `beforeCommitted()` silently returned without setting
    `txnCommitAttachment`. The transaction still committed with a null
    attachment written to EditLog. During checkpoint replay,
    `replayOnCommitted()` calls
    `Preconditions.checkNotNull(txnState.getTxnCommitAttachment())`,
    throwing NPE.
    
    Two issues fixed in `beforeCommitted()`:
    1. Throw `TransactionException` when task is canceled instead of silent
    `return`, preventing commit with null attachment. Consistent with
    `RoutineLoadJob.executeBeforeCheck()` pattern.
    2. Fix write lock leak — replaced broken `shouldReleaseLock` (always
    `false`) with `passCheck` pattern: release lock on failure in `finally`,
    keep it for `onStreamTaskSuccess/Fail()` to release on success.
---
 .../job/extensions/insert/streaming/StreamingInsertJob.java  | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/streaming/StreamingInsertJob.java
 
b/fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/streaming/StreamingInsertJob.java
index d7a325e22f5..8f0caec4be3 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/streaming/StreamingInsertJob.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/streaming/StreamingInsertJob.java
@@ -1021,13 +1021,13 @@ public class StreamingInsertJob extends 
AbstractJob<StreamingJobSchedulerTask, M
 
     @Override
     public void beforeCommitted(TransactionState txnState) throws 
TransactionException {
-        boolean shouldReleaseLock = false;
         writeLock();
+        boolean passCheck = false;
         try {
             if (runningStreamTask.getIsCanceled().get()) {
-                log.info("streaming insert job {} task {} is canceled, skip 
beforeCommitted",
-                        getJobId(), runningStreamTask.getTaskId());
-                return;
+                throw new TransactionException("streaming insert job " + 
getJobId()
+                        + " task " + runningStreamTask.getTaskId()
+                        + " is canceled, txn " + txnState.getTransactionId() + 
" could not be committed");
             }
 
             ArrayList<Long> taskIds = new ArrayList<>();
@@ -1046,7 +1046,6 @@ public class StreamingInsertJob extends 
AbstractJob<StreamingJobSchedulerTask, M
                     runningStreamTask.getTaskId(),
                     runningStreamTask.getScanBackendIds());
 
-
             if (StringUtils.isBlank(offsetJson)) {
                 throw new TransactionException("Cannot find offset for 
attachment, load job id is "
                         + runningStreamTask.getTaskId());
@@ -1059,8 +1058,9 @@ public class StreamingInsertJob extends 
AbstractJob<StreamingJobSchedulerTask, M
                         loadStatistic.getFileNumber(),
                         loadStatistic.getTotalFileSizeB(),
                         offsetJson));
+            passCheck = true;
         } finally {
-            if (shouldReleaseLock) {
+            if (!passCheck) {
                 writeUnlock();
             }
         }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to