Skip to content

MDEV-39788 CHANGE MASTER savefiles read and write one line to many#5148

Open
ParadoxV5 wants to merge 10 commits into
12.3from
MDEV-39788
Open

MDEV-39788 CHANGE MASTER savefiles read and write one line to many#5148
ParadoxV5 wants to merge 10 commits into
12.3from
MDEV-39788

Conversation

@ParadoxV5
Copy link
Copy Markdown
Contributor

@ParadoxV5 ParadoxV5 commented May 29, 2026

The MDEV-37530 refactor missed the detail that the line counts in @@master_info_file and @@relay_log_info_file also counted the line-count line itself.
Consequently, although fresh 12.3 installations and downgrades to earlier versions are unaffected, upgrades from pre-12.3 will encounter surprises when the 12.3 upgrade tries to read and discard the extra line:

  • master_use_gtid is reset to DEFAULT.
  • @@relay_log_info_file fails to load unless its data has previously shrunk.

(Explanation is in the bug description)

Since downgrading remained compatible, this commit fixes this content difference by correcting the code to read and write one fewer (unused) line.


(Ooh, how will our spambot treat merge commits? Well, to humans: it is temporary.)

ParadoxV5 added 2 commits May 29, 2026 12:06
MDEV-39788 found that the recent refactor on the `main` (now 12.3)
branch forgot that the line count includes the line count line itself.
This test checks future changes in any supported
version that they don’t make this mistake again.
@ParadoxV5 ParadoxV5 requested a review from bnestere May 29, 2026 18:37
@ParadoxV5 ParadoxV5 added MariaDB Corporation Replication Patches involved in replication labels May 29, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new regression test to verify the line count behavior of replication info files (master.info and relay-log.info). The reviewer provided feedback to improve test reliability and prevent flakiness, suggesting to shut down the server before modifying the replication info files to avoid Windows file locking and shutdown overwrite issues. Additionally, the reviewer recommended using start_mysqld.inc instead of restart_mysqld.inc to restart the server, and cleaning up the replication state using RESET SLAVE ALL; at the end of the test.

Comment on lines +13 to +15

# `using_gtid` is the key-value section, not the 33rd option.
--remove_file $MYSQLD_DATADIR/master.info
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Modifying master.info and relay-log.info while the server is running can cause test flakiness and failures:

  1. Windows File Locking: On Windows, the running mysqld process may hold active file locks on these files, causing --remove_file or --write_file to fail with permission errors.
  2. Shutdown Overwrite: When the server is restarted via restart_mysqld.inc, it first performs a shutdown. During shutdown, mysqld may flush its active replication state and overwrite the custom master.info and relay-log.info files you just wrote.

To avoid these issues, shut down the server before modifying the files, and then start it back up.

--source include/shutdown_mysqld.inc

# `using_gtid` is the key-value section, not the 33rd option.
--remove_file $MYSQLD_DATADIR/master.info

Comment on lines +67 to +68
--let $restart_parameters= --skip-slave-start
--source include/restart_mysqld.inc
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Since the server should be shut down before modifying the info files, use start_mysqld.inc here instead of restart_mysqld.inc to bring the server back up with the --skip-slave-start parameter.

--let $start_parameters= --skip-slave-start
--source include/start_mysqld.inc

Comment thread mysql-test/main/rpl_info_file_line_count.test Outdated
ParadoxV5 added 5 commits May 29, 2026 12:57
use RESET SLAVE ALL in case other tests restart the server without
specifying `--skip-slave-start` (why not default in MTR I do not know)
The MDEV-37530 refactor missed the detail that the line counts in
`@@master_info_file` and `@@relay_log_info_file`
also counted the line-count line itself.
Consequently, although fresh 12.3 installations
and downgrades to earlier versions are unaffected,
upgrades from pre-12.3 will encounter surprises when
the 12.3 upgrade tries to read and discard the extra line:
* `master_use_gtid` is reset to DEFAULT.
* `@@relay_log_info_file` fails to load
  unless its data has previously shrunk.

Since downgrading remained compatible,
this commit fixes this content difference by correcting
the code to read and write one fewer (unused) line.

Reviewed-by: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
@ParadoxV5 ParadoxV5 marked this pull request as ready for review May 29, 2026 22:08
@ParadoxV5
Copy link
Copy Markdown
Contributor Author

Oh right, still needa cover the directory separator difference on WinDoze…

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

Labels

MariaDB Corporation Replication Patches involved in replication

Development

Successfully merging this pull request may close these issues.

1 participant