Skip to content
/ server Public

MDEV-38020 Master & relay log info files read 2^31 and above incorrectly#4701

Open
FarihaIS wants to merge 1 commit intoMariaDB:10.6from
FarihaIS:mdev-38020
Open

MDEV-38020 Master & relay log info files read 2^31 and above incorrectly#4701
FarihaIS wants to merge 1 commit intoMariaDB:10.6from
FarihaIS:mdev-38020

Conversation

@FarihaIS
Copy link
Contributor

Description

Master and relay log position fields (relay_log_pos, master_log_pos) are 64-bit unsigned (ulonglong) but were read from info files using init_intvar_from_file() which calls atoi(), limiting values to signed 32-bit integers.

Add init_ullongvar_from_file() using my_strtoll10() to correctly parse 64-bit values. Update rpl_rli.cc and rpl_mi.cc to use ulonglong variables and this new function.

Release Notes

N/A

How can this PR be tested?

Execute the rpl.rpl_read_old_relay_log_info test in mysql-test-run. This commit adds a test in rpl_read_old_relay_log_info.test.

Before the fix

The test fails due to the relay_log_pos overflowing and becoming corrupted after a server restart.

rpl.rpl_read_old_relay_log_info 'stmt'   [ fail ]
        Test ended at 2026-02-26 20:05:30

CURRENT_TEST: rpl.rpl_read_old_relay_log_info
mysqltest: In included file "./include/assert.inc": 
included from /quick-rebuilds/mariadb/mysql-test/suite/rpl/t/rpl_read_old_relay_log_info.test at line 65:
At line 168: Test assertion failed in assertion.inc

The result from queries just before the failure was:
< snip >
Log_name        File_size
master-bin.000001       329

**** SHOW BINLOG EVENTS on server_1 ****
binlog_name = 'master-bin.000001'
SHOW BINLOG EVENTS IN 'master-bin.000001' LIMIT 200;
Log_name        Pos     Event_type      Server_id       End_log_pos     Info
master-bin.000001       4       Format_desc     1       256     Server ver: 10.6.26-MariaDB-log, Binlog ver: 4
master-bin.000001       256     Gtid_list       1       285     []
master-bin.000001       285     Binlog_checkpoint       1       329     master-bin.000001

**** SHOW RELAYLOG EVENTS on server_1 ****
relaylog_name = 'No such row'
SHOW RELAYLOG EVENTS IN 'No such row' LIMIT 200;
Log_name        Pos     Event_type      Server_id       End_log_pos     Info
connection server_2;
Assertion text: 'relay_log_pos should be 2147483648 after restart'
Assertion condition: '[SHOW SLAVE STATUS, Relay_Log_Pos, 1] = 2147483648'
Assertion condition, interpolated: '18446744071562067968 = 2147483648'
Assertion result: '0'

After the fix

The test passes as the 64-bit value is correctly preserved across server restarts.

rpl.rpl_read_old_relay_log_info 'mix'    [ pass ]   2835
rpl.rpl_read_old_relay_log_info 'row'    [ pass ]   2799
rpl.rpl_read_old_relay_log_info 'stmt'   [ pass ]   2804
--------------------------------------------------------------------------
The servers were restarted 2 times
Spent 8.438 of 14 seconds executing testcases

Completed: All 3 tests were successful.

Basing the PR against the correct MariaDB version

  • This is a bug fix, and the PR is based against the branch 10.6.

Copyright

All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.

Master and relay log positions are 64-bit unsigned but were read using
atoi(), which only handles signed 32-bit integers. Values >= 2^31 overflow
and corrupt after restart.

Add init_ullongvar_from_file() using my_strtoll10() to correctly parse
64-bit values. Update rpl_rli.cc and rpl_mi.cc to use ulonglong variables
and this new function.

All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the
BSD-new license. I am contributing on behalf of my employer Amazon Web
Services, Inc.
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@FarihaIS FarihaIS marked this pull request as ready for review February 26, 2026 22:05
@ParadoxV5 ParadoxV5 requested a review from bnestere February 26, 2026 22:08
@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Feb 27, 2026
@ParadoxV5 ParadoxV5 added the Replication Patches involved in replication label Feb 28, 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. Replication Patches involved in replication

Development

Successfully merging this pull request may close these issues.

4 participants