{"record":{"id":"435205967b9a1525","repo":"apache/seatunnel","slug":"failed-to-close-flush-timer-for-task","errorCode":null,"errorMessage":"Failed to close flush timer for task {}","messagePattern":"Failed to close flush timer for task (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/task/flow/SourceFlowLifeCycle.java","lineNumber":394,"sourceCode":"                        .registerTimerFlushTask(\n                                currentTaskLocation, this::onTimerTick, flushIntervalMs);\n        log.info(\n                \"Registered flush timer for source task {}, intervalMs={}\",\n                currentTaskLocation,\n                flushIntervalMs);\n    }\n\n    private void closeFlushTimer() {\n        if (flushFuture == null) {\n            return;\n        }\n        try {\n            runningTask\n                    .getExecutionContext()\n                    .getTaskExecutionService()\n                    .closeTimerFlushTask(currentTaskLocation);\n        } catch (Exception e) {\n            log.warn(\"Failed to close flush timer for task {}\", currentTaskLocation, e);\n        }\n        flushFuture = null;\n    }\n\n    /**\n     * Sends a split request to the remote split enumerator.\n     *\n     * <p>Sends a {@link RequestSplitOperation} to the enumerator, requesting new splits to be\n     * assigned to this reader. The enumerator will respond asynchronously by calling {@link\n     * #receivedSplits(List)}.\n     *\n     * @throws RuntimeException if the split request fails due to communication errors\n     */\n    public void requestSplit() {\n        try {\n            runningTask\n                    .getExecutionContext()\n                    .sendToMember(","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/task/flow/SourceFlowLifeCycle.java#L376-L412","documentation":"SourceFlowLifeCycle.closeFlushTimer (invoked from close()) asks the TaskExecutionService to close the periodic flush timer task for this source task. Failures are logged at WARN and non-fatal; flushFuture is nulled regardless. A lingering timer could produce harmless later ticks or minor resource retention.","triggerScenarios":"closeTimerFlushTask(currentTaskLocation) throws, e.g. the timer task was already removed, the task has been cancelled concurrently, or the TaskExecutionService is shutting down.","commonSituations":"Job cancellation racing with source close; node shutdown while closing tasks; repeated close attempts on the same flow lifecycle.","solutions":["Typically safe to ignore if it appears during job shutdown; verify no timer tasks remain via engine logs/monitoring.","If it occurs mid-run or repeatedly, check TaskExecutionService state and node logs for scheduling failures.","Avoid cancelling jobs twice concurrently; use one graceful stop path.","Upgrade if a timer-vs-teardown race is fixed in your target SeaTunnel version."],"exampleFix":"// before: double close attempts on the timer\nsourceFlowLifeCycle.close();\nsourceFlowLifeCycle.close(); // second close fails timer cleanup\n// after: guard with idempotent close (engine handles via flushFuture = null) and cancel once\nseaTunnel.sh -s <jobId> // single graceful stop","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// non-fatal: engine logs and nulls flushFuture\ntry {\n    job.execute();\n} finally {\n    // verify no residual timer tasks via engine metrics\n}","preventionTips":["Cancel jobs once, via a single graceful path.","Ignore occurrences confined to shutdown.","Monitor for repeated occurrences during normal running — indicates engine timer issues.","Keep SeaTunnel updated for timer/teardown race fixes."],"tags":["flush-timer","shutdown","source","non-fatal"],"backgroundTag":"resource-cleanup-timeout","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}