apache/seatunnel · warning

Failed to close binaryLogClient

Error message

Failed to close binaryLogClient

What it means

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.

Source

Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/source/reader/fetch/MySqlSourceFetchTaskContext.java:203

        this.snapshotChangeEventSourceMetrics =
                changeEventSourceMetricsFactory.getSnapshotMetrics(
                        taskContext, queue, metadataProvider);
        this.streamingChangeEventSourceMetrics =
                (MySqlStreamingChangeEventSourceMetrics)
                        changeEventSourceMetricsFactory.getStreamingMetrics(
                                taskContext, queue, metadataProvider);
        this.errorHandler = new MySqlErrorHandler(connectorConfig, queue);
    }

    @Override
    public void close() {
        try {
            this.connection.close();
            this.binaryLogClient.disconnect();
        } catch (SQLException e) {
            log.warn("Failed to close connection", e);
        } catch (IOException e) {
            log.warn("Failed to close binaryLogClient", e);
        }
    }

    @Override
    public MySqlSourceConfig getSourceConfig() {
        return (MySqlSourceConfig) sourceConfig;
    }

    public MySqlConnection getConnection() {
        return connection;
    }

    public BinaryLogClient getBinaryLogClient() {
        return binaryLogClient;
    }

    public MySqlTaskContextImpl getTaskContext() {
        return taskContext;

View on GitHub (pinned to cf67b549a7)

Solutions

  1. If it occurs during job shutdown after a failure, it is benign — verify the underlying cause of the earlier failure instead.
  2. Ensure the reader stops the fetch task (which stops the client cleanly) before close() is invoked.
  3. Check network/firewall timeouts that kill idle binlog connections; adjust keepalive settings.
  4. Wrap the disconnect in its own try/catch (as with the SQLException case) to avoid suppressing other cleanup.

Example fix

// before
try {
    this.connection.close();
    this.binaryLogClient.disconnect();
} catch (IOException e) { log.warn("Failed to close binaryLogClient", e); }
// after
try { this.binaryLogClient.disconnect(); } catch (IOException e) { log.warn("Failed to close binaryLogClient", e); }
Defensive patterns

Strategy: try-catch

Try / catch

try {
    binaryLogClient.disconnect();
} catch (IOException e) {
    log.warn("Failed to close binaryLogClient", e); // expected if client already died
}

Prevention

When it happens

Trigger: 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.

Common situations: Reader cancelled/failed mid-stream (binlog connection already dropped), MySQL server closed the connection, network interruption during shutdown, keepalive thread already terminated.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/a77867fb378e00c7. Report an issue: GitHub.