You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When using pg_chameleon with a MySQL source that experiences temporary connectivity issues, the read daemon crashes despite having on_error_read: continue configured. Similar to #69.
To Reproduce
Steps to reproduce the behavior:
Configure pg_chameleon with on_error_read: continue in the source configuration
Start replication
Shut the MySQL server after the __init_read_replica is finished but before the batch_data is finished
Connection times out
Instead of continuing and attempting to reconnect as configured, the read daemon crashes completely
Expected behavior
When on_error_read: continue is set, the read daemon should catch connection timeout errors, log them, and attempt to reconnect rather than crashing.
Environment:
OS: Debian
MySQL Version: 8.0.40
PostgreSQL Version: 17
Python Version: 3.11
Cloud hosted database: Selfhost
Additional context
The issue was previously addressed in commit 9b8e98a (for issue #69), but the fix is incomplete. While on_error_read is checked in __init_read_replica, the error occurring in the read_replica method when calling __read_replica_stream isn't caught.
Log snippet showing the crash:
2025-02-19 00:23:50 MainProcess ERROR: Read process alive: False - Replay process alive: True
2025-02-19 00:23:50 MainProcess ERROR: Stack trace: Traceback (most recent call last):
File "/home/REDACTED/chameleon/lib/python3.11/site-packages/pymysql/connections.py", line 649, in connect
sock = socket.create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/socket.py", line 851, in create_connection
raise exceptions[0]
File "/usr/lib/python3.11/socket.py", line 836, in create_connection
sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/REDACTED/chameleon/lib/python3.11/site-packages/pg_chameleon/lib/global_lib.py", line 535, in read_replica
self.mysql_source.read_replica()
File "/home/REDACTED/chameleon/lib/python3.11/site-packages/pg_chameleon/lib/mysql_lib.py", line 1527, in read_replica
replica_data=self.__read_replica_stream(batch_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/REDACTED/chameleon/lib/python3.11/site-packages/pg_chameleon/lib/mysql_lib.py", line 1290, in __read_replica_stream
for binlogevent in my_stream:
File "/home/REDACTED/chameleon/lib/python3.11/site-packages/pymysqlreplication/binlogstream.py", line 587, in fetchone
self.__connect_to_stream()
File "/home/REDACTED/chameleon/lib/python3.11/site-packages/pymysqlreplication/binlogstream.py", line 349, in __connect_to_stream
self._stream_connection = self.pymysql_wrapper(**self.__connection_settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/REDACTED/chameleon/lib/python3.11/site-packages/pymysql/connections.py", line 361, in __init__
self.connect()
File "/home/REDACTED/chameleon/lib/python3.11/site-packages/pymysql/connections.py", line 716, in connect
raise exc
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'REDACTED' ([Errno 110] Connection timed out)")
2025-02-19 00:23:50 MainProcess ERROR: Read daemon crashed. Terminating the replay daemon.
2025-02-19 00:23:50 MainProcess INFO: Replica process for source mysql ended
While on_error_read is set correctly as shown here:
Suggested fix would be to wrap the __read_replica_stream call in a try/except block that handles connection errors in accordance with the on_error_read setting.
The text was updated successfully, but these errors were encountered:
Describe the bug
When using pg_chameleon with a MySQL source that experiences temporary connectivity issues, the read daemon crashes despite having
on_error_read: continue
configured. Similar to #69.To Reproduce
Steps to reproduce the behavior:
on_error_read: continue
in the source configurationExpected behavior
When
on_error_read: continue
is set, the read daemon should catch connection timeout errors, log them, and attempt to reconnect rather than crashing.Environment:
Additional context
The issue was previously addressed in commit 9b8e98a (for issue #69), but the fix is incomplete. While
on_error_read
is checked in__init_read_replica
, the error occurring in theread_replica
method when calling__read_replica_stream
isn't caught.Log snippet showing the crash:
While
on_error_read
is set correctly as shown here:pg_chameleon/pg_chameleon/lib/mysql_lib.py
Lines 870 to 881 in 5458575
The call to
__read_replica_stream
inread_replica
is not wrapped in a try/except block that would respect this setting:pg_chameleon/pg_chameleon/lib/mysql_lib.py
Lines 1499 to 1527 in 5458575
Suggested fix would be to wrap the
__read_replica_stream
call in a try/except block that handles connection errors in accordance with theon_error_read
setting.The text was updated successfully, but these errors were encountered: