julien-duponchelle / python-mysql-replication

Pure Python Implementation of MySQL replication protocol build on top of PyMYSQL
2.31k stars 678 forks source link

A wrong warning message is logged for every event from ignored table #578

Closed YAtOff closed 9 months ago

YAtOff commented 10 months ago

Version

Please specify the versions you are using. Exact version numbers are preferred.

System Variables

List relevant system variables using the query SHOW VARIABLES LIKE '<variable_name_here>';

If you are using MySQL 8.0.14 or later, please also provide the following variables:

Symptoms

The message is A pymysql.OperationalError error occurred, causing a fake rotate event and initialization of the table_map. But there is no fake rotate event.

Steps to Reproduce

Initialize BinLogStreamReader with only_tables=[#some tables,...] and start iterating it.

Expected Outcome

No warning is logged.

Actual Outcome

Then for each event from a table that is not in the table list, the warning is logged.

My interpretation of the issue

The issue is caused by this PR: https://github.com/julien-duponchelle/python-mysql-replication/pull/490 If I understand correctly, the table_map should be empty when we have a fake rotate event. But here, it is not empty. It just doesn't have a key for the table. It is possible, too, that the table is empty, but that's because no events have been received yet for the tables we are interested in. I think a flag for the rotation is needed.

Planning to Resolve

sean-k1 commented 10 months ago

@YAtOff Hello. Thanks for reporting. Yes I think we should consider when filter table cases.

We need capture fake rotate Event.

dongwook-chan commented 9 months ago

@YAtOff Thank you for reporting the issue. Could you please provide the list of arguments that you passed to BinLogStreamReader?

YAtOff commented 9 months ago

@YAtOff Thank you for reporting the issue. Could you please provide the list of arguments that you passed to BinLogStreamReader?

I'll give you the exact code. The exact values are not necessary.

    stream = BinLogStreamReader(
          connection_settings=MYSQL_SETTINGS,
          server_id=cdc_settings['MYSQL_SERVER_ID'],
          blocking=True,
          only_schemas=[schema],
          only_tables=[file_table, fileversion_table],
          only_events=[WriteRowsEvent, UpdateRowsEvent, GtidEvent],
          resume_stream=True,
          log_file=log_pos.file,
          log_pos=log_pos.position
    )