{"record":{"id":"463d0023974a01c4","repo":"apache/seatunnel","slug":"close-jdbc-writer-failed","errorCode":null,"errorMessage":"Close JDBC writer failed.","messagePattern":"Close JDBC writer failed\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/JdbcOutputFormat.java","lineNumber":253,"sourceCode":"                flush();\n            } catch (Exception e) {\n                LOG.warn(\"Writing records to JDBC failed.\", e);\n                flushException =\n                        new JdbcConnectorException(\n                                CommonErrorCodeDeprecated.FLUSH_DATA_FAILED,\n                                \"Writing records to JDBC failed.\",\n                                e);\n            }\n        }\n    }\n\n    public void closeStatements() {\n        try {\n            if (jdbcStatementExecutor != null) {\n                jdbcStatementExecutor.closeStatements();\n            }\n        } catch (SQLException | JdbcConnectorException e) {\n            LOG.warn(\"Close JDBC writer failed.\", e);\n        }\n    }\n\n    private boolean isOverMaxBatchSizeLimit() {\n        return jdbcConnectionConfig.getBatchSize() > 0\n                && batchCount >= jdbcConnectionConfig.getBatchSize();\n    }\n\n    private boolean isOverMaxBatchIntervalLimit() {\n        long batchIntervalMs = jdbcConnectionConfig.getBatchIntervalMs();\n        return batchIntervalMs > 0\n                && (System.currentTimeMillis() - lastFlushTimeMs) >= batchIntervalMs;\n    }\n\n    public void updateExecutor(boolean reconnect) throws SQLException, ClassNotFoundException {\n        try {\n            jdbcStatementExecutor.closeStatements();\n        } catch (SQLException | JdbcConnectorException e) {","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/JdbcOutputFormat.java#L235-L271","documentation":"closeStatements() attempts to close the underlying JdbcStatementExecutor's statements when the writer is closed. Any SQLException or JdbcConnectorException is caught, logged as a warning ('Close JDBC writer failed.'), and swallowed — it never propagates to the task. This is a best-effort cleanup log, not a task failure.","triggerScenarios":"close() -> closeStatements() while the underlying Connection/Statement is already broken (connection reset, socket timeout) or the driver throws SQLException on Statement.close().","commonSituations":"Database restarted or network dropped before job completion (common when a prior flush already failed); driver-specific quirks throwing on close of a dead statement; leaked statements after long-running jobs.","solutions":["Check the logged cause: if it follows a FLUSH_DATA_FAILED error, fix that root cause first","Verify network/firewall idle-timeout settings that kill connections before job close","Upgrade the JDBC driver if it throws spuriously on close of dead statements","Treat this warning as benign cleanup noise if all records were flushed successfully"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"// before closing, verify connection liveness\nif (connection != null && !connection.isValid(5)) {\n    log.info(\"connection already dead; close warning expected\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    outputFormat.close();\n} catch (Exception e) {\n    // close() itself rarely throws for this path; watch logs for 'Close JDBC writer failed.'\n    log.warn(\"cleanup close issue\", e);\n}","preventionTips":["Fix earlier FLUSH_DATA_FAILED errors — most close failures follow them","Keep connections alive across job duration (timeouts, keepalive)","Monitor this warning only; it is non-fatal by design"],"tags":["jdbc","cleanup","resource-leak","warning"],"backgroundTag":"database-query-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}