Skip to content
/ server Public

MDEV-35767: Prevent MTR from overwriting list-like options in test-specific .cnf files#4792

Open
MicheleFilisina wants to merge 4 commits intoMariaDB:mainfrom
MicheleFilisina:MDEV-35767-fix
Open

MDEV-35767: Prevent MTR from overwriting list-like options in test-specific .cnf files#4792
MicheleFilisina wants to merge 4 commits intoMariaDB:mainfrom
MicheleFilisina:MDEV-35767-fix

Conversation

@MicheleFilisina
Copy link

Currently, MTR fails to properly concatenate list-like options (such as replicate_do_table) when they are declared on multiple lines inside a '.cnf' file. Because the MTR parser reads .cnf files into a dictionary/hash structure, so duplicate keys simply overwrite the previous ones.

This patch updates 'mysql-test/lib/My/Config.pm' to normalize incoming option names (stripping leading dashes and exchanging underscores for dashes) prior to checking if they require multipart concatenation. If the option is a known list property and already exists, instead of overwriting the previous value MTR will concatenate the new value onto the existing one separated by a comma.

Added a new MTR test suite scenario with multiple 'replicate-do-table' declarations to prove the property correctly via SHOW VARIABLES.

Also i'm a new contributor (and a student) so i'm kinda newbie. Thus even, though i made my best, i'm not sure to have followed all the guidelines and this code might be a bit 'buggy'. So i'd appreciate a thorough review on the code.

@CLAassistant
Copy link

CLAassistant commented Mar 12, 2026

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 Mar 12, 2026
@gkodinov gkodinov changed the title Mdev 35767: Prevent MTR from overwriting list-like options in test-specific .cnf files MDEV-35767: Prevent MTR from overwriting list-like options in test-specific .cnf files Mar 12, 2026
Copy link
Member

@gkodinov gkodinov left a comment

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 have a single commit.
And have it contain a commit message that complies to CODING_STANDARDS.md
Also, please target 10.11 : this is a bug fix.

sub insert {
my ($self, $option_name, $value, $if_not_exist)= @_;
my $option= $self->option($option_name);
if (defined($option) and !$if_not_exist) {
Copy link
Member

Choose a reason for hiding this comment

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

I do not think you should be touching this function at all. mtr already supports multi-value variables.

return $group->options();
}

#
Copy link
Member

Choose a reason for hiding this comment

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

you do not need this.

croak "group '$group_name' does not exist"
unless defined($group);

my $option= $group->option($option_name);
Copy link
Member

Choose a reason for hiding this comment

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

don't change this please

@@ -0,0 +1,3 @@
SHOW VARIABLES LIKE 'replicate_do_table';
Variable_name Value
replicate_do_table
Copy link
Member

Choose a reason for hiding this comment

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

Your test should have printed the 3 tables. and it doesn't.

@@ -0,0 +1,3 @@
SHOW VARIABLES LIKE 'replicate_do_table';
Copy link
Member

Choose a reason for hiding this comment

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

disable the test for embedded.

(
"plugin-load-add" => 1,
"optimizer-switch" => 1,
"replicate-do-table" => 1,
Copy link
Member

Choose a reason for hiding this comment

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

This is the only addition that should be kept. Also, please add a unit tests for this in mariadb-test-run.pl!

@mikegriffin
Copy link
Contributor

There are a few more multi-value filter names:

BINLOG_DO_DB
BINLOG_IGNORE_DB
REPLICATE_DO_DB
REPLICATE_DO_TABLE
REPLICATE_IGNORE_DB
REPLICATE_IGNORE_TABLE
REPLICATE_REWRITE_DB
REPLICATE_WILD_DO_TABLE
REPLICATE_WILD_IGNORE_TABLE

@@ -0,0 +1,3 @@
SHOW VARIABLES LIKE 'replicate_do_table';
Variable_name Value
replicate_do_table test.t3,test.t1,test.t2
Copy link
Member

Choose a reason for hiding this comment

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

is the order of these predictable in the server?

Maybe if it isn't, the they can be ordered with this test:

SELECT tbl
FROM JSON_TABLE(
    CONCAT('[', @@replicate_do_table, ']'),]
    '$[*]' COLUMNS (
        tbl VARCHAR(16) PATH '$'
    )
) AS jt
ORDER BY tbl;

Copy link
Author

Choose a reason for hiding this comment

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

i had the same suspicion

Copy link
Author

Choose a reason for hiding this comment

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

i tried your query and it gave me syntax error.
wouldn't this one be better?

SELECT GROUP_CONCAT(tbl ORDER BY tbl) AS sorted_replicate_do_table
FROM JSON_TABLE(
    CONCAT('["', REPLACE(@@replicate_do_table, ',', '","'), '"]'),
    '$[*]' COLUMNS (
        tbl VARCHAR(255) PATH '$'
    )
) AS jt;

Change list_parsing.test so that the output is always sorted, add multi-value filter names to Config.pm
Change list_parsing.test so that the output is always sorted, add multi-value filter names to Config.pm
@MicheleFilisina
Copy link
Author

MicheleFilisina commented Mar 13, 2026

i didn't add a test for each multi-value filter name, but i tested them locally, also, should i open a new pull request to target 10.11?

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.

Development

Successfully merging this pull request may close these issues.

5 participants