Permalink
Browse files

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.
  • Loading branch information...
vartec committed Jun 17, 2015
1 parent 647ccee commit 4c48538168f4cd3239563393a29b542cc6ffcf4b
Showing with 14 additions and 1 deletion.
  1. +14 −1 pymysqlreplication/row_event.py
@@ -547,7 +547,20 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection, **kwargs)
self.packet.read_length_coded_binary()
for i in range(0, len(column_types)):
column_type = column_types[i]
column_schema = self.column_schemas[i]
try:
column_schema = self.column_schemas[i]
except IndexError:
# this a dirty hack to prevent row evens containing columns which have been dropped prior
# to pymysqlreplication start, but replayed from binlog from blowing up the service.
# TODO: this does not address the issue if the column other than the last one is dropped
column_schema = {
'COLUMN_NAME': '__dropped_col_{i}__'.format(i=i),
'COLLATION_NAME': None,
'CHARACTER_SET_NAME': None,
'COLUMN_COMMENT': None,
'COLUMN_TYPE': 'BLOB', # we don't know what it is, so let's not do anything with it.
'COLUMN_KEY': '',
}
col = Column(byte2int(column_type), column_schema, from_packet)
self.columns.append(col)

0 comments on commit 4c48538

Please sign in to comment.