File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -160,6 +160,16 @@ def fetchone(self):
160
160
if binlog_event .event_type == ROTATE_EVENT :
161
161
self .log_pos = binlog_event .event .position
162
162
self .log_file = binlog_event .event .next_binlog
163
+ # Table Id in binlog are NOT persistent in MySQL - they are in-memory identifiers
164
+ # that means that when MySQL master restarts, it will reuse same table id for different tables
165
+ # which will cause errors for us since our in-memory map will try to decode row data with
166
+ # wrong table schema.
167
+ # The fix is to rely on the fact that MySQL will also rotate to a new binlog file every time it
168
+ # restarts. That means every rotation we see *could* be a sign of restart and so potentially
169
+ # invalidates all our cached table id to schema mappings. This means we have to load them all
170
+ # again for each logfile which is potentially wasted effort but we can't really do much better
171
+ # without being broken in restart case
172
+ self .table_map = {}
163
173
elif binlog_event .log_pos :
164
174
self .log_pos = binlog_event .log_pos
165
175
You can’t perform that action at this time.
0 commit comments