github-actions[bot] commented on code in PR #66530:
URL: https://github.com/apache/doris/pull/66530#discussion_r3781088434


##########
fe/fe-core/src/main/java/org/apache/doris/job/executor/TaskProcessor.java:
##########
@@ -82,6 +84,22 @@ private void runTask(AbstractTask task) {
             task.runTask();
         } catch (Exception e) {
             log.warn("Execute task error, task id: {}", task.getTaskId(), e);
+        } finally {
+            closeTaskContext();
+        }
+    }
+
+    private void closeTaskContext() {
+        ConnectContext connectContext = ConnectContext.get();

Review Comment:
   **[P2] Clean up every MTMV context before replacing it**
   
   This finalizer only sees the `ConnectContext` currently installed on the 
worker. `MTMVTask` creates and installs a fresh context for every refresh 
chunk/retry, but an earlier execution can return from 
`InsertIntoTableCommand.runInternal` as an empty insert before 
`executeSingleInsert` reaches its `unregisterQuery` finally (and a 
pre-coordinator planning failure has the same shape). If planning already 
created connector metadata or query-finish callbacks, the next `exec` 
overwrites the thread-local context and this code can clean only the last one, 
leaving the earlier scope/callbacks without deterministic teardown. Please make 
each MTMV `exec` own complete query/scope cleanup after its coordinator and 
split pumps quiesce, then remove or restore its thread-local context; add a 
test that installs two successive contexts in one task and verifies both are 
closed.



-- 
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]

Reply via email to