-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
MDEV-35635: START SLAVE UNTIL allows CHANGE MASTER TO options #3909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @MohanadKh03 !
Thanks for submitting the patch with a test case already! I've left a few suggestions to the test, and then a couple more suggestions for the git commit message itself:
- Please keep each line to 72 characters in length
- Git commit messages don't support markdown, so you can remove/simplify the formatting a bit (though note the PR description does support markdown)
- Can you re-phrase/extend the problem description to start off with a description that is more user-facing? That is, a typical user won't know what "master_file_def options" are, but you can describe the problem without using that phrase. Then later in the commit message, you can mention it (as it is good to still mention this for developers).
# Clean up after tests. | ||
DROP TABLE t1; | ||
source include/rpl_end.inc; | ||
# ==== End of test ==== |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you echo
the "End of test" line? And also end the file in a new line.
|
||
connection slave; | ||
-- error ER_PARSE_ERROR | ||
start slave until master_log_file='$master_log_file', master_log_pos=$master_log_pos_1, MASTER_USE_GTID=NO, MASTER_DEMOTE_TO_SLAVE=1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To use value substitution (using for variables set via the let
mysqltest construct), you need to start the line with the mysqltest command eval
. So this should be
start slave until master_log_file='$master_log_file', master_log_pos=$master_log_pos_1, MASTER_USE_GTID=NO, MASTER_DEMOTE_TO_SLAVE=1; | |
eval start slave until master_log_file='$master_log_file', master_log_pos=$master_log_pos_1, MASTER_USE_GTID=NO, MASTER_DEMOTE_TO_SLAVE=1; |
Though to the complete test case, I don't think you actually need to use substitution at all, as you are just testing parsing options. So ultimately I'd say you could do something like
start slave until master_log_file='$master_log_file', master_log_pos=$master_log_pos_1, MASTER_USE_GTID=NO, MASTER_DEMOTE_TO_SLAVE=1; | |
--error ER_PARSE_ERROR | |
start slave until master_log_file='master-bin.000001', master_log_pos=4, MASTER_USE_GTID=NO, MASTER_DEMOTE_TO_SLAVE=1; | |
--error ER_BAD_SLAVE | |
start slave until master_log_file='master-bin.000001', master_log_pos=4; |
and a few other options to test completeness.
# MDEV-35635 | ||
# Testing issues around invalid parameters and START SLAVE UNTIL behavior. | ||
|
||
# Include necessary configurations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need any pre-amble source
for this test, as it is just testing parsing. I think really all that this test needs are the actual start slave
lines, no set-up data is needed. Then, for a "passing" test, you can just set the expectation ER_BAD_SLAVE
(as no slave is actually configured, but it proves the parsing has gone through)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @MohanadKh03 ,
Looks great, thanks! I very much appreciate the spelling out of the test description and git commit message :)
I'm going to pass review along to our replication QA engineer, @mariadb-SusilBehera , to give an extra set of eyes to your MTR test.
# | ||
# Valid query options (using only slave options) | ||
# | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here could you --echo
to restate
ER_BAD_SLAVE
: Dummy error which should be treated as a passing test as this is a parser test not a logical one
So when looking through the .result
file, it is stated that the error is good?
sql/sql_yacc.yy
Outdated
| RELAY_LOG_POS_SYM '=' ulong_num | ||
{ | ||
Lex->mi.relay_log_pos = $3; | ||
Lex->mi.relay_log_pos= MY_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to just use $3, like in MASTER_LOG_POS_SYM
's definition. Also, can you reiterate the comment about what this MY_MAX
operator is for, as is done with master_file_def
Lex->mi.relay_log_pos= MY_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos); | |
/* Adjust if < BIN_LOG_HEADER_SIZE (same comment as master_file_dif rule for MASTER_LOG_POS_SYM) */ | |
Lex->mi.relay_log_pos= MY_MAX(BIN_LOG_HEADER_SIZE, $3); |
--error ER_BAD_SLAVE | ||
START slave UNTIL MASTER_GTID_POS = '0-1-1'; | ||
|
||
# Clean up after tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no clean up to be done, so you can probably just remove this line altogether
START slave UNTIL MASTER_GTID_POS = '0-1-1'; | ||
|
||
# Clean up after tests. | ||
--echo ==== End of test ==== |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--echo ==== End of test ==== | |
--echo ==== End of test main.start_slave_until ==== |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added just one more review comment.
; | ||
|
||
slave_until_file_def: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MASTER_GTID_POS is missing here. Shouldn't we include an entry for this here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really needed inside this one this is just for handling master/slave combinations for MASTER/SLAVE_LOG_FILE and MASTER/SLAVE_LOG_POS
but MASTER_GTID_POS_SYM is already in the slave_until
rule
Lines 8397 to 8400 in 2fe28c6
| UNTIL_SYM MASTER_GTID_POS_SYM '=' TEXT_STRING_sys | |
{ | |
Lex->mi.gtid_pos_str = $4; | |
Lex->mi.is_until_before_gtids= false; |
5b57a37
to
4e73f9e
Compare
To report on the status of this ticket, the work has been reviewed and accepted, and is waiting to be QA tested as part of the 12.1 sprint, which is planned to start on June 3. |
Restrict START SLAVE UNTIL to slave options disallowing master options START SLAVE UNTIL was allowing both slave and master options, which could cause confusion and misconfigurations. This commit fixes that by restricting it to these valid slave options: - MASTER_LOG_FILE, MASTER_LOG_POS - RELAY_LOG_FILE, RELAY_LOG_POS - MASTER_GTID_POS The parser change replaces `master_file_def` with `slave_until_file_def` in `sql_yacc.yy`, making sure master options like MASTER_USE_GTID and MASTER_DEMOTE_TO_SLAVE aren’t allowed anymore.
Description
This commit separates master's options from slave options in
sql_yacc.yy
by replacingmaster_file_def
withslave_until_file_def
which only contain the options needed in the query:These are the only options valid in this query
MASTER_LOG_FILE_SYM, MASTER_LOG_POS_SYM, RELAY_LOG_FILE_SYM and RELAY_LOG_POS_SYM and MASTER_GTID_POS
This is only a change in the symbols the START SLAVE command did not use any functionalty related to what was included in
master_file_def
Release Notes
How can this PR be tested?
This can be tested using
start_slave_until.test
file which should test valid options queries and invalid onesInvalid being anything that is not part of this
MASTER_LOG_FILE_SYM, MASTER_LOG_POS_SYM, RELAY_LOG_FILE_SYM and RELAY_LOG_POS_SYM and MASTER_GTID_POS
Basing the PR against the correct MariaDB version
main
branch.PR quality check