Repository navigation
Conversation
The timestamp, server id, event size and next-event position are unsigned 32-bit. Read signed, a next position past 2 GiB became negative, EventInfo ignored it, and BinLogCurrent stopped advancing inside a binlog file that a large transaction grew past 2 GiB.
The extra data length counts its own two bytes (rows_event.cpp reads it and subtracts 2), but findTableMap() skipped length / 8 bytes. For the usual length 2 that skipped nothing, which was right by chance. MySQL 8.0.16+ writes the partition id into every rows event of a partitioned table (typecode plus one or two 2-byte ids, length 5 or 7), which was left unread: a two-row INSERT into a HASH-partitioned table decoded as garbage rows. Skip length - 2.
cyppe
marked this pull request as ready for review
November 14, 2026 13:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two independent read errors in event decoding, one commit each:
Event header fields read signed (
Event::createEventInfo()). The timestamp, server id, event size and next-event position are unsigned 32-bit (binlog_event.h). Read signed, a next position past 2 GiB became negative.EventInforecords only positive positions, soBinLogCurrent, the resume position, stopped advancing inside a binlog file that a large transaction grew past 2 GiB. They are read withreadUInt32()now. With semi-sync replication enabled, the acknowledgement now also carries the real position past 2 GiB rather than an older one. On 32-bit PHP,readUInt32()still returns negative values abovePHP_INT_MAX, as before; this change is for 64-bit PHP.v2 rows-event extra data skipped as
length / 8bytes (RowEvent::findTableMap()). The length counts its own two bytes (rows_event.cppreads it, then subtracts 2). For the usual length 2 the old code skipped nothing, which was right by chance. MySQL 8.0.16+ writes the partition id into every rows event of a partitioned table: a typecode plus one or two 2-byte ids, so a length of 5 or 7. Those bytes were left unread. On MySQL 8.4, a two-row INSERT into aPARTITION BY HASHtable decoded as wrong rows with no error. The fix skipslength - 2bytes.Tests:
EventConsumeHeaderTest::testNextPositionPastTwoGibibytesAdvancesTheBinLogPositionconsumes one header whose next position is0x90000000.BasicTest::testShouldDecodeRowEventsOfAPartitionedTablecovers insert, update across partitions, and delete on a hash-partitioned table. It is skipped on MariaDB and on MySQL before 8.0.16, which write no partition info.Both fail on
masterand pass with the fix. The full suite passes locally against MySQL 8.4.13, MySQL 5.7.44 and MariaDB 11.4 (PHP 8.4). The PHP 8.2 CI cells fail onmastertoo (PHPUnit 12 needs PHP 8.3, see #159).This is the fourth of the small decoder fixes, after #161, #162 and #163, and is independent of them. The zero-length socket read that ends a payload of exactly 16 MiB − 1 is handled in #158, so it is not repeated here.