Skip to content

Add missing MySQL 8.0+ binlog event types (36-42)#143

Merged
krowinski merged 1 commit intokrowinski:masterfrom
cyppe:fix/support-transaction-payload-event
Feb 25, 2026
Merged

Add missing MySQL 8.0+ binlog event types (36-42)#143
krowinski merged 1 commit intokrowinski:masterfrom
cyppe:fix/support-transaction-payload-event

Conversation

@cyppe
Copy link
Contributor

@cyppe cyppe commented Feb 9, 2026

Problem

The ConstEventType enum is missing all event types added in MySQL 8.0+ (types 36–42), causing a ValueError crash when the library encounters any of them:

[ValueError]
39 is not a valid backing value for enum MySQLReplication\Definitions\Const\EventType

The most commonly triggered one is PARTIAL_UPDATE_ROWS_EVENT (type 39), which MySQL emits when binlog_row_value_options=PARTIAL_JSON is enabled — a common optimization for tables with JSON columns.

Another likely trigger is TRANSACTION_PAYLOAD_EVENT (type 40), emitted when binlog_transaction_compression is enabled.

The crash occurs in EventInfo::__construct() where ConstEventType::from() is called with an unrecognized type value.

Current workaround (lossy)

Users can disable the MySQL settings that emit these events (binlog_row_value_options= and binlog_transaction_compression=OFF), but this means MySQL falls back to writing full row images — losing the binlog space savings these features provide. More importantly, without this fix there is no way to use these MySQL features with this library at all.

Changes

  1. Added all missing MySQL 8.0+ event types to ConstEventType, per binlog_event.h:

    Type Name Trigger
    36 TRANSACTION_CONTEXT_EVENT Group Replication
    37 VIEW_CHANGE_EVENT Group Replication
    38 XA_PREPARE_LOG_EVENT XA transactions
    39 PARTIAL_UPDATE_ROWS_EVENT binlog_row_value_options=PARTIAL_JSON
    40 TRANSACTION_PAYLOAD_EVENT binlog_transaction_compression=ON
    41 HEARTBEAT_LOG_EVENT_V2 MySQL 8.0.26+ heartbeat
    42 GTID_TAGGED_LOG_EVENT Tagged GTIDs
  2. Changed from() to tryFrom() in EventInfo — so any future unrecognized event types are handled gracefully instead of crashing. The event will be silently skipped by Event::makeEvent() which already returns null for unhandled types.

Note: This PR adds the event types to the enum so they don't crash, but does not add handlers for them (e.g. decompressing TRANSACTION_PAYLOAD_EVENT or parsing partial JSON diffs from PARTIAL_UPDATE_ROWS_EVENT). These events are silently skipped by Event::makeEvent(). Full handler support could be added in follow-up PRs.

Why CI doesn't catch this

The test workflow's my-cnf only sets binlog_format=row and binlog_rows_query_log_events=ON. It does not enable binlog_row_value_options=PARTIAL_JSON or binlog_transaction_compression=ON, so MySQL never emits event types 39/40 during CI. These are common production settings.

…acefully

The ConstEventType enum is missing all event types added in MySQL 8.0+
(types 36-42), causing a ValueError crash when the library encounters
any of them. The most commonly triggered one is PARTIAL_UPDATE_ROWS_EVENT
(type 39), emitted when binlog_row_value_options=PARTIAL_JSON is enabled.

Changes:
- Add all missing MySQL 8.0+ event types to ConstEventType:
  - TRANSACTION_CONTEXT_EVENT (36)
  - VIEW_CHANGE_EVENT (37)
  - XA_PREPARE_LOG_EVENT (38)
  - PARTIAL_UPDATE_ROWS_EVENT (39)
  - TRANSACTION_PAYLOAD_EVENT (40)
  - HEARTBEAT_LOG_EVENT_V2 (41)
  - GTID_TAGGED_LOG_EVENT (42)
- Use tryFrom() instead of from() in EventInfo to gracefully handle
  any future unrecognized event types instead of crashing

Ref: https://github.com/mysql/mysql-server/blob/824e2b4064053f7daf17d7f3f84b7a3ed92e5fb4/libs/mysql/binlog/event/binlog_event.h#L285
@cyppe cyppe force-pushed the fix/support-transaction-payload-event branch from 99ceea5 to 625c483 Compare February 9, 2026 13:49
@cyppe cyppe changed the title Add TRANSACTION_PAYLOAD_EVENT (type 39) for MySQL 8.0.20+ Add missing MySQL 8.0+ binlog event types (36-42) Feb 9, 2026
@krowinski krowinski merged commit 1a0d1c5 into krowinski:master Feb 25, 2026
9 checks passed
@krowinski
Copy link
Owner

tx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants