You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* This commit addresses an issue where acknowledgments (ACKs) were sometimes sent to the master before binlog events were fully written and fsynced to disk during backup operations. Sending ACKs prematurely in semi-synchronous replication could lead to data loss if the replica fails after sending the ACK but before persisting the event.
Key changes:
- Introduced an `EventHandler` interface with a `HandleEvent` method for
processing binlog events. This allows custom event handling logic to
be injected into the replication stream.
- Added an `eventHandler` field to `BinlogSyncer` and provided a
`SetEventHandler` method to assign an event handler. This enables
`BinlogSyncer` to delegate event processing to the assigned handler.
- Implemented `BackupEventHandler` which writes binlog events to disk
and ensures that each event is fsynced before returning. This ensures
data durability before ACKs are sent.
- Modified the `onStream` method in `BinlogSyncer` to separate event
parsing (`parseEvent`) from event handling and ACK sending
(`handleEventAndACK`). This adheres to the single-responsibility
principle and makes the code cleaner.
- Moved state updates (e.g., updating `b.nextPos`) and GTID set handling
from `parseEvent` to `handleEventAndACK` to avoid side effects during
parsing.
- Ensured that ACKs are sent only after the event has been fully
processed and fsynced by sending the ACK in `handleEventAndACK` after
event handling.
* Refactor event handling by replacing SyncMode and EventHandleMode with SynchronousEventHandler. Simplify the event processing in BinlogSyncerConfig by introducing SynchronousEventHandler for synchronous event handling. Update StartBackup, StartBackupWithHandler, and associated tests to reflect these changes.
* Add some comments and remember to remove SetEventHandler and the eventHandler attribute
* Remove the timeout for synchronous backup, revert the timeout move to return the behavior to 30 days _between_ events, restore some comments, use struct instead of bool as recommended, add a note about SynchronousEventHandler and the parseEvent return values
* Make sure to assign the timeout on the syncer so the backup doesn't fail
* Make sure to add NewBackupHandler in order to expose the otherwise private handler outside the package
---------
Co-authored-by: Dylan Terry <[email protected]>
0 commit comments