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 1 commit intoMariaDB:10.11from
MicheleFilisina:MDEV-35767-fix
Open

MDEV-35767: Prevent MTR from overwriting list-like options in test-specific .cnf files#4792
MicheleFilisina wants to merge 1 commit intoMariaDB:10.11from
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.

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';
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.

@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;

Copy link
Member

Choose a reason for hiding this comment

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

that works. I was rough estimating with a numeric example. Thanks for working it out.

Copy link
Member

Choose a reason for hiding this comment

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

the order is important IMHO

@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?

@grooverdan
Copy link
Member

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?

you can rebase your commits to 10.11, squash them up, git force push to the same branch and this PR will updated. Then edit the title of this PR - there's the target branch listed there, change that to 10.11.

@MicheleFilisina MicheleFilisina changed the base branch from main to 10.11 March 14, 2026 22:15
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.

Looks much better! Thanks for working on this.
Some polishing suggestions below.

@@ -0,0 +1,8 @@
--source include/not_embedded.inc
SELECT GROUP_CONCAT(tbl ORDER BY tbl) AS sorted_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.

I do not mind the nice derived table etc, but I'd just do SELECT @@replicate_do_table. The order should be stable.

Copy link
Author

@MicheleFilisina MicheleFilisina Mar 16, 2026

Choose a reason for hiding this comment

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

Oh, I didn't know the order is deterministic. Thanks for the advice 👍.

!include include/default_my.cnf

[mysqld.1]
replicate_do_table=test.t1
Copy link
Member

Choose a reason for hiding this comment

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

Do you really need to prefix these with "test." ? And does it need to be 3 lines? IMHO 2 would do just fine.

Copy link
Member

Choose a reason for hiding this comment

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

Also, please try to keep a single commit. the github PR UI has as "rebase" button: use that if you need to update your branch. Or the equivalent on the command line.

Copy link
Author

@MicheleFilisina MicheleFilisina Mar 16, 2026

Choose a reason for hiding this comment

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

Do you really need to prefix these with "test." ? And does it need to be 3 lines? IMHO 2 would do just fine.

I tested removing the "test." prefix, but i belive it causes the server to crash on startup (it dies after 0.06 seconds). In var/log i get this error: [ERROR] Could not add do table rule 't1'.
It seems the configuration strictly requires the database.table format.

But i'm not sure though, what do you think?

…te Option

Add some multi-part options to Config.pm, Add a test case for list parsing in mysqltest_multi_opt_replicate_do
@MicheleFilisina
Copy link
Author

I was wondering if it would be better to add tests for other multi-options as well?

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