{"record":{"id":"a77867fb378e00c7","repo":"apache/seatunnel","slug":"failed-to-close-binarylogclient","errorCode":null,"errorMessage":"Failed to close binaryLogClient","messagePattern":"Failed to close binaryLogClient","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/source/reader/fetch/MySqlSourceFetchTaskContext.java","lineNumber":203,"sourceCode":"        this.snapshotChangeEventSourceMetrics =\n                changeEventSourceMetricsFactory.getSnapshotMetrics(\n                        taskContext, queue, metadataProvider);\n        this.streamingChangeEventSourceMetrics =\n                (MySqlStreamingChangeEventSourceMetrics)\n                        changeEventSourceMetricsFactory.getStreamingMetrics(\n                                taskContext, queue, metadataProvider);\n        this.errorHandler = new MySqlErrorHandler(connectorConfig, queue);\n    }\n\n    @Override\n    public void close() {\n        try {\n            this.connection.close();\n            this.binaryLogClient.disconnect();\n        } catch (SQLException e) {\n            log.warn(\"Failed to close connection\", e);\n        } catch (IOException e) {\n            log.warn(\"Failed to close binaryLogClient\", e);\n        }\n    }\n\n    @Override\n    public MySqlSourceConfig getSourceConfig() {\n        return (MySqlSourceConfig) sourceConfig;\n    }\n\n    public MySqlConnection getConnection() {\n        return connection;\n    }\n\n    public BinaryLogClient getBinaryLogClient() {\n        return binaryLogClient;\n    }\n\n    public MySqlTaskContextImpl getTaskContext() {\n        return taskContext;","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/source/reader/fetch/MySqlSourceFetchTaskContext.java#L185-L221","documentation":"MySqlSourceFetchTaskContext.close() disconnects the mysql-binlog-connector-java BinaryLogClient after closing the JDBC connection. If disconnect() throws IOException (client already disconnected, broken socket, event stream error), this warning is logged.","triggerScenarios":"close() calls this.binaryLogClient.disconnect(); the client's internal event thread is already dead or the socket is broken, and disconnect() throws IOException, caught and logged.","commonSituations":"Reader cancelled/failed mid-stream (binlog connection already dropped), MySQL server closed the connection, network interruption during shutdown, keepalive thread already terminated.","solutions":["If it occurs during job shutdown after a failure, it is benign — verify the underlying cause of the earlier failure instead.","Ensure the reader stops the fetch task (which stops the client cleanly) before close() is invoked.","Check network/firewall timeouts that kill idle binlog connections; adjust keepalive settings.","Wrap the disconnect in its own try/catch (as with the SQLException case) to avoid suppressing other cleanup."],"exampleFix":"// before\ntry {\n    this.connection.close();\n    this.binaryLogClient.disconnect();\n} catch (IOException e) { log.warn(\"Failed to close binaryLogClient\", e); }\n// after\ntry { this.binaryLogClient.disconnect(); } catch (IOException e) { log.warn(\"Failed to close binaryLogClient\", e); }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    binaryLogClient.disconnect();\n} catch (IOException e) {\n    log.warn(\"Failed to close binaryLogClient\", e); // expected if client already died\n}","preventionTips":["Stop the fetch task cleanly before closing the context","Ignore IOException on disconnect after an earlier stream failure","Configure keepalive on the BinaryLogClient to reduce dead sockets","Check network/firewall idle timeouts for long-running binlog streams"],"tags":["mysql","binlog","resource-cleanup","shutdown"],"backgroundTag":"broken-pipe","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"}