zhangshenghang opened a new issue, #13318: URL: https://github.com/apache/seatunnel/issues/13318
### What happened Cancelling a task before its restore arrives closes the task while `writer` is still null: `SinkFlowLifeCycle.close()` NPEs and the exception skips the close of every remaining lifecycle (transforms and the source reader), leaking connector resources. Chain (dev @ 89f91a89af): 1. `SinkFlowLifeCycle` creates its writer **only** in `restoreState` (`SinkFlowLifeCycle.java:406-412`, `createWriter`/`restoreWriter`) — not in `init()`. 2. A task cancelled while in `WAITING_RESTORE` (a common recovery timing: another task group in the pipeline failed first and the pipeline is cancelling everything) reaches `SeaTunnelTask.close()` via the `CANCELLING` state (`SeaTunnelTask.java:309-311`) or via BlockingWorker's finally (`TaskExecutionService.java:1321-1330`). 3. `SinkFlowLifeCycle.close()` calls `writer.close()` unguarded (`SinkFlowLifeCycle.java:276-283`) → NPE while `writer == null`. 4. `SeaTunnelTask.close()` catches only `IOException` per lifecycle (`SeaTunnelTask.java:483-496`), so the NPE propagates and skips all remaining lifecycles' close. Since `convertFlowToActionLifeCycle` registers downstream lifecycles first (`SeaTunnelTask.java:347-405`: sink early, source last), the skipped ones include the **source reader** — its connections/threads leak until worker restart. ### Trigger Any pipeline failure that cancels a deployed-but-not-yet-restored sink task group — i.e., the ordinary first moments of every pipeline restore. ### Impact Connector resource leak (source connections, threads, file handles) on every restore that cancels a WAITING_RESTORE sink group; the NPE also masks the original error in worker logs. ### Suggested fix - Null-guard `writer` in `SinkFlowLifeCycle.close()`. - Make `SeaTunnelTask.close()` resilient per lifecycle (catch `Throwable`, collect, keep closing the rest), so one failing close cannot skip the others. ### SeaTunnel Version dev (89f91a89af), Zeta engine -- 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]
