Skip to content

Commit

Permalink
fake rotate event check
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-k1 committed Nov 23, 2023
1 parent ca3ab06 commit 396d4d4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 9 additions & 1 deletion pymysqlreplication/binlogstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ def __check_optional_meta_data(self):

def fetchone(self):
while True:
fake_rotate_flag = False
if self.end_log_pos and self.is_past_end_log_pos:
return None

Expand All @@ -596,6 +597,13 @@ def fetchone(self):
if code in MYSQL_EXPECTED_ERROR_CODES:
self._stream_connection.close()
self.__connected_stream = False
logging.log(
logging.WARN,
"""
A pymysql.OperationalError error occurred, Re-request the connection.
""",
)
fake_rotate_flag = True
continue
raise

Expand Down Expand Up @@ -623,7 +631,7 @@ def fetchone(self):
self.__optional_meta_data,
)

if binlog_event.event_type == ROTATE_EVENT:
if binlog_event.event_type == ROTATE_EVENT and not fake_rotate_flag:
self.log_pos = binlog_event.event.position
self.log_file = binlog_event.event.next_binlog
# Table Id in binlog are NOT persistent in MySQL - they are in-memory identifiers
Expand Down
6 changes: 0 additions & 6 deletions pymysqlreplication/row_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection, **kwargs)
self.table = self.table_map[self.table_id].table
except KeyError: # If we have filter the corresponding TableMap Event
self._processed = False
logging.log(
logging.WARN,
"""
A pymysql.OperationalError error occurred, causing a fake rotate event and initialization of the table_map
""",
)
return

if self.__only_tables is not None and self.table not in self.__only_tables:
Expand Down

0 comments on commit 396d4d4

Please sign in to comment.