Skip to content

Commit 4c48538

Browse files
author
Bartek Ogryczak
committed
Partial fix for dropped columns blowing up replication when replaying binlog with past events
Mitigates following errror: File "/usr/local/lib/python2.7/dist-packages/pymysqlreplication/binlogstream.py", line 262, in fetchone self.__freeze_schema) File "/usr/local/lib/python2.7/dist-packages/pymysqlreplication/packet.py", line 98, in __init__ freeze_schema = freeze_schema) File "/usr/local/lib/python2.7/dist-packages/pymysqlreplication/row_event.py", line 550, in __init__ column_schema = self.column_schemas[i] IndexError: list index out of range This is just a superficial patch. It does not address deeper issue at hand, which is that pymysqlreplication has no good way of handling RowEvents containing columns which have been dropped prior to pymsqlreplication start. The problem is always relying on current version of information_schema even though dealing with events that might be several versions in the past.
1 parent 647ccee commit 4c48538

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

pymysqlreplication/row_event.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,20 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection, **kwargs)
547547
self.packet.read_length_coded_binary()
548548
for i in range(0, len(column_types)):
549549
column_type = column_types[i]
550-
column_schema = self.column_schemas[i]
550+
try:
551+
column_schema = self.column_schemas[i]
552+
except IndexError:
553+
# this a dirty hack to prevent row evens containing columns which have been dropped prior
554+
# to pymysqlreplication start, but replayed from binlog from blowing up the service.
555+
# TODO: this does not address the issue if the column other than the last one is dropped
556+
column_schema = {
557+
'COLUMN_NAME': '__dropped_col_{i}__'.format(i=i),
558+
'COLLATION_NAME': None,
559+
'CHARACTER_SET_NAME': None,
560+
'COLUMN_COMMENT': None,
561+
'COLUMN_TYPE': 'BLOB', # we don't know what it is, so let's not do anything with it.
562+
'COLUMN_KEY': '',
563+
}
551564
col = Column(byte2int(column_type), column_schema, from_packet)
552565
self.columns.append(col)
553566

0 commit comments

Comments
 (0)