-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Description
After upgrading our MariaDB database to version 11.4.1, the canal module of the go-mysql library stopped detecting row updates within transactions. This issue seems to be linked to the handling of fake rotate events that I added a few years ago. The problem stems from an incorrect assumption that events with LogPos=0 can be ignored. However, it appears that the new version of MariaDB does not specify LogPos for certain events:
Events written through transaction or statement cache have log_pos set
to 0 so that they can be copied directly to the binlog without having
to compute the real end_log_pos.
Relevant code in MariaDB: MariaDB log_event_server.cc - MariaDB/server@b8f9f79
Steps to Reproduce:
- Setup MariaDB 10.7.7.
- Configure the canal module to process binlog events.
- Execute a transaction that updates rows in the database.
- Check that the row updates are handled correctly.
- Upgrade MariaDB to version 11.4.1.
- Execute a transaction that updates rows in the database.
- Observe that the canal module does not detect the row updates.
Expected Behavior:
The canal module should detect and process row updates within transactions, regardless of the LogPos value.
Actual Behavior:
The canal module ignores events with LogPos=0, causing it to miss row updates within transactions.
Environment:
- MariaDB version: 11.4.1
- go-mysql version: 1.8.0
- OS: Alpine 3.20
Additional Context
The issue seems to be related to a change in how MariaDB handles LogPos for events written through transaction or statement cache. To resolve this, the canal module needs to be updated to handle events with LogPos=0 appropriately.
Proposed Solution
Consider fake rotate events only for events of type ROTATE_EVENT with timestamp = 0. This aligns with the comment in the MySQL codebase indicating that the timestamp is set to 0 to distinguish FAKE_ROTATE_EVENT from ROTATE_EVENT and conforms to the MariaDB documentation on fake rotate events.