From b6921bbfb07d37ead22a0697499fe1c753896ef6 Mon Sep 17 00:00:00 2001 From: ParadoxV5 Date: Fri, 29 May 2026 11:55:48 -0600 Subject: [PATCH 1/6] Test for MDEV-39788 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../main/rpl_info_file_line_count.result | 12 +++ mysql-test/main/rpl_info_file_line_count.test | 75 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 mysql-test/main/rpl_info_file_line_count.result create mode 100644 mysql-test/main/rpl_info_file_line_count.test diff --git a/mysql-test/main/rpl_info_file_line_count.result b/mysql-test/main/rpl_info_file_line_count.result new file mode 100644 index 0000000000000..ebe9052cb50c4 --- /dev/null +++ b/mysql-test/main/rpl_info_file_line_count.result @@ -0,0 +1,12 @@ +CHANGE MASTER TO master_host='127.0.0.1'; +5 +./mysqld-relay-bin.000001 +4 + +0 +0 +# restart: --skip-slave-start +Master_SSL_Key = '' +Using_Gtid = 'Current_Pos' +SQL_Delay = '0' +CHANGE MASTER TO master_use_gtid=slave_pos; diff --git a/mysql-test/main/rpl_info_file_line_count.test b/mysql-test/main/rpl_info_file_line_count.test new file mode 100644 index 0000000000000..bb77b8ab508d8 --- /dev/null +++ b/mysql-test/main/rpl_info_file_line_count.test @@ -0,0 +1,75 @@ +# Line count / upgrading test for `@@master_info_file` & `@@relay_log_info_file` +# +# This regression test reminds that the line count includes the line count line. +# +# Reference: +# MDEV-39788 CHANGE MASTER savefiles read and write one line to many + +--source include/have_binlog_format_mixed.inc # format-agnostic +CHANGE MASTER TO master_host='127.0.0.1'; # have_info_files + +--let $MYSQLD_DATADIR= `SELECT @@datadir` + + +# `using_gtid` is the key-value section, not the 33rd option. +--remove_file $MYSQLD_DATADIR/master.info +--write_file $MYSQLD_DATADIR/master.info +33 + +4 +127.0.0.1 +root + +3306 +60 +1 + + + + + +1 +60.000 + + + +101010 + + + + + + + + + + + + + +using_gtid=1 +EOF + +# This file does not have the 6th option +# (neither does the current `@@relay_log_info_file`). +--cat_file $MYSQLD_DATADIR/relay-log.info +--remove_file $MYSQLD_DATADIR/relay-log.info +--write_file $MYSQLD_DATADIR/relay-log.info +6 +./mysqld-relay-bin.000001 +4 + +0 +0 +EOF + + +--let $restart_parameters= --skip-slave-start +--source include/restart_mysqld.inc + +--let $status_items= Master_SSL_Key, Using_Gtid, SQL_Delay +--source include/show_slave_status.inc + + +# Reset +CHANGE MASTER TO master_use_gtid=slave_pos; From cef52e2269473606440f605d03cb3793e43ae415 Mon Sep 17 00:00:00 2001 From: ParadoxV5 Date: Fri, 29 May 2026 12:57:49 -0600 Subject: [PATCH 2/6] fixup 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) --- mysql-test/main/rpl_info_file_line_count.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/rpl_info_file_line_count.test b/mysql-test/main/rpl_info_file_line_count.test index bb77b8ab508d8..caea07e2a5d7e 100644 --- a/mysql-test/main/rpl_info_file_line_count.test +++ b/mysql-test/main/rpl_info_file_line_count.test @@ -33,7 +33,7 @@ root -101010 +100000 @@ -72,4 +72,4 @@ EOF # Reset -CHANGE MASTER TO master_use_gtid=slave_pos; +RESET SLAVE ALL; From ea00d4c2cf02dd4883ad96a5bb410c5599797c65 Mon Sep 17 00:00:00 2001 From: ParadoxV5 Date: Fri, 29 May 2026 15:04:45 -0600 Subject: [PATCH 3/6] MDEV-39788 CHANGE MASTER savefiles read and write one line to many 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 --- sql/rpl_info_file.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sql/rpl_info_file.h b/sql/rpl_info_file.h index 493598f7bf5a8..3d98034dffbc2 100644 --- a/sql/rpl_info_file.h +++ b/sql/rpl_info_file.h @@ -294,9 +294,9 @@ struct Info_file auto &line1= dynamic_cast &>(values[0](this)); if (line1.load_from(&file)) return true; - char *end= str2int(line1.buf, 10, 0, INT32_MAX, &val); + char *end= str2int(line1.buf, 10, 1, INT32_MAX, &val); /** - If this first line was not a number - the line count, + If this first line was not a positive number - the line count, then it was the first value for real, so the for loop should then skip over it, the index 0 of the list. */ @@ -305,7 +305,8 @@ struct Info_file Set the default after parsing: While std::from_chars() does not replace the output if it failed, it does replace if the line is not fully spent. */ - size_t line_count= i ? default_line_count: static_cast(val); + size_t line_count= i ? default_line_count : + static_cast(val - 1); // remove the line count line from the count for (; i < line_count; ++i) { int c; @@ -355,10 +356,11 @@ struct Info_file } /* Pad additional reserved lines: - (1 for the line count line + line count) inclusive -> max line inclusive - = line count exclusive <- max line inclusive + (1 for the line count line + line count) exclusive -> max line inclusive + = line count exclusive -> max line exclusive */ - for (; total_line_count > size; --total_line_count) + // Pad additional reserved lines + while ((++size) < total_line_count) my_b_write_byte(&file, '\n'); } From 78ac3f84e04310aaef4b54dd5ad24994f408600d Mon Sep 17 00:00:00 2001 From: ParadoxV5 Date: Fri, 29 May 2026 16:07:08 -0600 Subject: [PATCH 4/6] =?UTF-8?q?ye=20smol=20problem=20with=20test-result=20?= =?UTF-8?q?pairs=20is=20that=20it=E2=80=99s=20easy=20to=20forget=20to=20up?= =?UTF-8?q?date=20the=20result?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mysql-test/main/rpl_info_file_line_count.result | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/rpl_info_file_line_count.result b/mysql-test/main/rpl_info_file_line_count.result index ebe9052cb50c4..af9a1ee8989c8 100644 --- a/mysql-test/main/rpl_info_file_line_count.result +++ b/mysql-test/main/rpl_info_file_line_count.result @@ -9,4 +9,6 @@ CHANGE MASTER TO master_host='127.0.0.1'; Master_SSL_Key = '' Using_Gtid = 'Current_Pos' SQL_Delay = '0' -CHANGE MASTER TO master_use_gtid=slave_pos; +RESET SLAVE ALL; +Warnings: +Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'Current_Pos' to 'Slave_Pos' From df587c18a2a9cef6048048f24fc6c2b28a60a370 Mon Sep 17 00:00:00 2001 From: ParadoxV5 Date: Fri, 29 May 2026 16:15:46 -0600 Subject: [PATCH 5/6] whoops. (RIP our CI today) --- mysql-test/main/rpl_info_file_line_count.result | 6 ------ mysql-test/main/rpl_info_file_line_count.test | 1 - 2 files changed, 7 deletions(-) diff --git a/mysql-test/main/rpl_info_file_line_count.result b/mysql-test/main/rpl_info_file_line_count.result index af9a1ee8989c8..0a747059c5558 100644 --- a/mysql-test/main/rpl_info_file_line_count.result +++ b/mysql-test/main/rpl_info_file_line_count.result @@ -1,10 +1,4 @@ CHANGE MASTER TO master_host='127.0.0.1'; -5 -./mysqld-relay-bin.000001 -4 - -0 -0 # restart: --skip-slave-start Master_SSL_Key = '' Using_Gtid = 'Current_Pos' diff --git a/mysql-test/main/rpl_info_file_line_count.test b/mysql-test/main/rpl_info_file_line_count.test index caea07e2a5d7e..568618e61442f 100644 --- a/mysql-test/main/rpl_info_file_line_count.test +++ b/mysql-test/main/rpl_info_file_line_count.test @@ -52,7 +52,6 @@ EOF # This file does not have the 6th option # (neither does the current `@@relay_log_info_file`). ---cat_file $MYSQLD_DATADIR/relay-log.info --remove_file $MYSQLD_DATADIR/relay-log.info --write_file $MYSQLD_DATADIR/relay-log.info 6 From 0d654f6bbf9643158792c4f2b69fbbf7af8c9ddb Mon Sep 17 00:00:00 2001 From: ParadoxV5 Date: Fri, 29 May 2026 17:46:02 -0600 Subject: [PATCH 6/6] =?UTF-8?q?didn=E2=80=99t=20notice=20that=20null=20lis?= =?UTF-8?q?ts=20were=20allowed=20in=20pre-12.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mysql-test/main/rpl_info_file_line_count.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/main/rpl_info_file_line_count.test b/mysql-test/main/rpl_info_file_line_count.test index 568618e61442f..aa338f6c37463 100644 --- a/mysql-test/main/rpl_info_file_line_count.test +++ b/mysql-test/main/rpl_info_file_line_count.test @@ -31,7 +31,7 @@ root 1 60.000 - +0 100000