-
Enhancement
-
Resolution: Done
-
Major
-
None
-
None
-
False
-
-
False
Description
Currently, when the database.server.id in Debezium's MySQL connector is incorrectly configured with the same value as another replica, the connector encounters the following error:
[2025-03-14 13:21:44,217] ERROR Error during binlog processing. Last offset stored = {file=mysql-bin.000181, pos=8170305, gtids=252e9f91-bb98-11ef-a15a-fa163e803807:1-16831817,d2a53a06-bb98-11ef-8071-fa163eba37fc:1-167000, server_id=5351, event=1}, binlog reader near position = mysql-bin.000181/8170305 (io.debezium.connector.binlog.BinlogStreamingChangeEventSource) Mar 14, 2025 1:21:44 PM com.github.shyiko.mysql.binlog.BinaryLogClient$5 run INFO: threadExecutor is shut down, terminating keepalive thread [2025-03-14 13:21:44,227] ERROR Producer failure (io.debezium.pipeline.ErrorHandler) io.debezium.DebeziumException: A replica with the same server_uuid/server_id as this replica has connected to the source; the first event '' at 4, the last event read from '/log/mysql-log/mysql-bin.000181' at 8170305, the last byte read from '/log/mysql-log/mysql-bin.000181' at 8170305. Error code: 1236; SQLSTATE: HY000. at io.debezium.connector.binlog.BinlogStreamingChangeEventSource.wrap(BinlogStreamingChangeEventSource.java:1190) at io.debezium.connector.binlog.BinlogStreamingChangeEventSource$ReaderThreadLifecycleListener.onCommunicationFailure(BinlogStreamingChangeEventSource.java:1235) at com.github.shyiko.mysql.binlog.BinaryLogClient.listenForEventPackets(BinaryLogClient.java:1105) at com.github.shyiko.mysql.binlog.BinaryLogClient.connect(BinaryLogClient.java:655) at com.github.shyiko.mysql.binlog.BinaryLogClient$7.run(BinaryLogClient.java:954) at java.base/java.lang.Thread.run(Unknown Source) Caused by: com.github.shyiko.mysql.binlog.network.ServerException: A replica with the same server_uuid/server_id as this replica has connected to the source; the first event '' at 4, the last event read from '/log/mysql-log/mysql-bin.000181' at 8170305, the last byte read from '/log/mysql-log/mysql-bin.000181' at 8170305. at com.github.shyiko.mysql.binlog.BinaryLogClient.listenForEventPackets(BinaryLogClient.java:1069) ... 3 more [2025-03-14 13:21:44,228] WARN Retry 1 of unlimited retries will be attempted (io.debezium.pipeline.ErrorHandler) [2025-03-14 13:21:44,230] INFO Stopped reading binlog after 0 events, last recorded offset: {file=mysql-bin.000181, pos=8170305, gtids=252e9f91-bb98-11ef-a15a-fa163e803807:1-16831817,d2a53a06-bb98-11ef-8071-fa163eba37fc:1-167000, server_id=5351, event=1} (io.debezium.connector.binlog.BinlogStreamingChangeEventSource) [2025-03-14 13:21:44,356] WARN Going to restart connector after 10 sec. after a retriable exception (io.debezium.connector.common.BaseSourceTask) [2025-03-14 13:21:44,373] INFO Finished streaming (io.debezium.pipeline.ChangeEventSourceCoordinator) [2025-03-14 13:21:44,375] INFO SignalProcessor stopped (io.debezium.pipeline.signal.SignalProcessor) [2025-03-14 13:21:44,375] INFO Debezium ServiceRegistry stopped. (io.debezium.service.DefaultServiceRegistry) [2025-03-14 13:21:44,384] ERROR Exception while closing JDBC connection (io.debezium.connector.mysql.MySqlConnectorTask) java.sql.SQLNonTransientConnectionException: Communications link failure during rollback(). Transaction resolution unknown. at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:102) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:81) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:55) at com.mysql.cj.jdbc.ConnectionImpl.rollback(ConnectionImpl.java:1964) at com.mysql.cj.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:1769) at com.mysql.cj.jdbc.ConnectionImpl.close(ConnectionImpl.java:703) at io.debezium.jdbc.JdbcConnection.lambda$doClose$4(JdbcConnection.java:982) at java.base/java.util.concurrent.FutureTask.run(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.base/java.lang.Thread.run(Unknown Source) [2025-03-14 13:21:44,385] INFO Connection gracefully closed (io.debezium.jdbc.JdbcConnection) [2025-03-14 13:21:44,386] INFO [Producer clientId=limtan-my-s7803-schemahistory] Closing the Kafka producer with timeoutMillis = 30000 ms. (org.apache.kafka.clients.producer.KafkaProducer) [2025-03-14 13:21:44,389] INFO Metrics scheduler closed (org.apache.kafka.common.metrics.Metrics) [2025-03-14 13:21:44,390] INFO Closing reporter org.apache.kafka.common.metrics.JmxReporter (org.apache.kafka.common.metrics.Metrics) [2025-03-14 13:21:44,390] INFO Closing reporter org.apache.kafka.common.telemetry.internals.ClientTelemetryReporter (org.apache.kafka.common.metrics.Metrics) [2025-03-14 13:21:44,390] INFO Metrics reporters closed (org.apache.kafka.common.metrics.Metrics) [2025-03-14 13:21:44,390] INFO App info kafka.producer for limtan-my-s7803-schemahistory unregistered (org.apache.kafka.common.utils.AppInfoParser) [2025-03-14 13:21:44,391] WARN WorkerSourceTask{id=limtan-my-s7803-leo-source-sbtest1-0} failed to poll records from SourceTask. Will retry operation. (org.apache.kafka.connect.runtime.AbstractWorkerSourceTask) org.apache.kafka.connect.errors.RetriableException: An exception occurred in the change event producer. This connector will be restarted. at io.debezium.pipeline.ErrorHandler.setProducerThrowable(ErrorHandler.java:63) at io.debezium.connector.binlog.BinlogStreamingChangeEventSource$ReaderThreadLifecycleListener.onCommunicationFailure(BinlogStreamingChangeEventSource.java:1235) at com.github.shyiko.mysql.binlog.BinaryLogClient.listenForEventPackets(BinaryLogClient.java:1105) at com.github.shyiko.mysql.binlog.BinaryLogClient.connect(BinaryLogClient.java:655) at com.github.shyiko.mysql.binlog.BinaryLogClient$7.run(BinaryLogClient.java:954) at java.base/java.lang.Thread.run(Unknown Source) Caused by: io.debezium.DebeziumException: A replica with the same server_uuid/server_id as this replica has connected to the source; the first event '' at 4, the last event read from '/log/mysql-log/mysql-bin.000181' at 8170305, the last byte read from '/log/mysql-log/mysql-bin.000181' at 8170305. Error code: 1236; SQLSTATE: HY000. at io.debezium.connector.binlog.BinlogStreamingChangeEventSource.wrap(BinlogStreamingChangeEventSource.java:1190) ... 5 more Caused by: com.github.shyiko.mysql.binlog.network.ServerException: A replica with the same server_uuid/server_id as this replica has connected to the source; the first event '' at 4, the last event read from '/log/mysql-log/mysql-bin.000181' at 8170305, the last byte read from '/log/mysql-log/mysql-bin.000181' at 8170305. at com.github.shyiko.mysql.binlog.BinaryLogClient.listenForEventPackets(BinaryLogClient.java:1069) ... 3 more
In such cases, the connector keeps retrying indefinitely. This can lead to confusion for users who are not actively monitoring logs, making it difficult to identify the root cause.
Proposed Improvement:
- Modify the error handling behavior so that when this specific error is encountered, the connector fails immediately (fail fast) rather than retrying endlessly.
- This behavior will make it easier for users to detect misconfigurations quickly and take corrective action without unnecessary downtime.
Suggested Implementation:
- Extend the existing DBMS-specific error handlers (MySqlErrorHandler, MariaDbErrorHandler).