Skip to content

MDEV-40545 mariadb-binlog --force-read loops on truncated events - #5784

Open
GoldenEmperor1177 wants to merge 1 commit into
MariaDB:10.11from
GoldenEmperor1177:MDEV-40545
Open

GoldenEmperor1177 wants to merge 1 commit into
MariaDB:10.11from
GoldenEmperor1177:MDEV-40545

Conversation

@GoldenEmperor1177

Copy link
Copy Markdown

mariadb-binlog --force-read can return a synthetic Unknown_log_event after a truncated event-header read without advancing the input position. dump_local_log_entries() then processes the synthetic event and repeatedly reads the same offset, causing an infinite loop.

This patch detects a non-null event returned without forward progress, deletes it, and routes execution through the existing read-error path. The command now terminates with:

ERROR: Could not read entry at offset 4: Error in log format or read error.

An MTR regression test recreates the malformed loop.001 input and verifies that mariadb-binlog --force-read exits instead of looping.

Tests on the 10.11 branch:

  • main.mysqlbinlog_force_read: passed
  • main.mysqlbinlog: passed
  • Direct reproduction: exited normally with status 1
  • git diff --check: passed

Thanks to Raja Sai Pranav for identifying the non-advancing --force-read path and suggesting the forward-progress guard implemented here.

Jira: https://jira.mariadb.org/browse/MDEV-40545

@CLAassistant

CLAassistant commented Sep 29, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Sep 30, 2026

@gkodinov gkodinov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! This is a preliminary review.

Please squash your two commits into one. And add a commit message that's compliant to the coding standards, in essence:

MDEV reference

- what was wrong
- how was it fixed
- how is the fix tested.
@gkodinov gkodinov self-assigned this Sep 30, 2026
@GoldenEmperor1177
GoldenEmperor1177 force-pushed the MDEV-40545 branch 2 times, most recently from e5b16d8 to 1e9c474 Compare September 30, 2026 09:08
With --force-read, a truncated event header could return a synthetic
Unknown_log_event without advancing the input position. The local binlog
dump loop treated the non-NULL event as successful and repeatedly read
the same offset.

Detect a successful-looking read that leaves the file position unchanged,
delete the synthetic event, and route it through the existing read-error
path.

Add an MTR regression test using a 17-byte binlog whose event header is
truncated. The test verifies that mariadb-binlog reports the read error
and exits instead of looping.

@gkodinov gkodinov left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please stand by for the final review.

For the record: do not push out incomplete changes!!! This makes it harder for me to process these.

@gkodinov
gkodinov requested a review from bnestere September 30, 2026 09:16
@gkodinov gkodinov assigned bnestere and unassigned gkodinov Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

4 participants