python-mysql-replication icon indicating copy to clipboard operation
python-mysql-replication copied to clipboard

resume_stream attribute of BinLogStreamReader not working as documented

Open jmanuelnavarro opened this issue 6 years ago • 7 comments

According to documentation, BinLogStreamReader starts from a given position if an specific position of the binlog file is assigned to log_pos and resume_stream = True. Nevertheless:

  • when resume_stream = true, whatever value I assigned to log_pos, no past events are retrieved in the steam.
  • when resume_tream = false, stream retrieves events since log_pos It seems the behaviour is different as the documented. Could you clarify it, please? Thanks in advance.

jmanuelnavarro avatar Aug 27 '19 09:08 jmanuelnavarro

Same experience here, I am unable to reattach properly to the stream. In case of error in my processing pipeline I would like to start from this point and skip all previous events.

telemmaite avatar Feb 10 '20 14:02 telemmaite

We are facing the same issue here.

marcusmadeiramadeira avatar Feb 10 '20 19:02 marcusmadeiramadeira

Time a scarce resource. Feel free to contribute a fix or a test case for your usecases :)

baloo avatar Feb 10 '20 23:02 baloo

resume_stream will take effect only when both log_file and log_pos are specified. If any of log_file and log_pos are not specified, they are queried with show master status. Just log_pos is not enough, log_file is necessary.

YAtOff avatar Feb 20 '20 15:02 YAtOff

@YAtOff Correct.

In my opinion, mysql replication using log_file and log_pos is and has always been risky and difficult to operate. You should consider GTID and support is working fine in python-mysql-replication (the product I'm working on, is relying on it and it works flawlessly).

baloo avatar Feb 20 '20 17:02 baloo

Had the same problem and ended up fetching the earliest log file by running SHOW BINARY LOGS - just take the first record and pass it to BinLogStreamReader (as log_file and log_pos).

fox avatar Jul 28 '20 15:07 fox

Had the same issue too. Added a hacky way to keep track of the position via a file: https://github.com/wilbertom/python-mysql-replication/commit/3a3b38e11e300367dd812e3306f22317beef2d6d . Just leaving a breadcrumb in case someone needs some psudo code.

In production I will probably keep it in some database.

wilbertom avatar May 10 '22 17:05 wilbertom