-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
MDEV-7611 mysqldump --dump-slave always starts stopped slave #3780
base: 10.5
Are you sure you want to change the base?
Conversation
Create a Multi-Source Replication test for these `mariadb-dump --dump-slave` bugs: * MDEV-7611 (not fixed as of this commit) * MDEV-5624 (fixed a long time ago)
static int do_start_slave_sql(MYSQL *mysql_con) | ||
{ | ||
MYSQL_RES *slave; | ||
MYSQL_ROW row; | ||
int error= 0; | ||
DBUG_ENTER("do_start_slave_sql"); | ||
|
||
/* We need to check if the slave sql is stopped in the first place */ | ||
if (mysql_query_with_error_report(mysql_con, &slave, | ||
multi_source ? | ||
"SHOW ALL SLAVES STATUS" : | ||
"SHOW SLAVE STATUS")) | ||
DBUG_RETURN(1); | ||
|
||
while ((row= mysql_fetch_row(slave))) | ||
for (; n_stopped_replicas--;) |
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 the new list instead of SHOW SLAVE STATUS, I essentially rewrote do_start_slave_sql
…
stopped_replicas= my_malloc(PSI_NOT_INSTRUMENTED, | ||
slave->row_count*NAME_CHAR_LEN + 1, MYF(MY_WME)); |
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 feel that it’s wrong wasting memory on short names and already-stopped replicas, but I feel that it’s more wrong spending extra effort realloc
ing unpredictably.
I’d like to iterate the MYSQL_RES
an additional time before the following loop to sum up name sizes of (only) active replications.
Question: How to rewind it from mysql_fetch_row()
s?
Note I didn’t check size overflow here because of the Broken Windows Theory:
Line 1986 in 6aa47fa
if (!(tmp=(char*) my_malloc(PSI_NOT_INSTRUMENTED, length*2+1, MYF(MY_WME)))) |
Line 6620 in 6aa47fa
result= my_malloc(PSI_NOT_INSTRUMENTED, result_length + 10, MYF(MY_WME)); |
@@ -6123,6 +6135,8 @@ static int do_stop_slave_sql(MYSQL *mysql_con) | |||
mysql_free_result(slave); | |||
return 1; | |||
} | |||
strmov(stopped_replicas[n_stopped_replicas++], | |||
multi_source ? row[0] : ""); |
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.
pedantically supporting no-multi-source on a best effort basis
(But those pre-10.0 versions were long-EOL… 😕)
Lines 7010 to 7015 in 6aa47fa
/* Check if the server support multi source */ | |
if (mysql_get_server_version(mysql) >= 100000) | |
{ | |
multi_source= 2; | |
have_mariadb_gtid= 1; | |
} |
char* stopped_replica= stopped_replicas[n_stopped_replicas]; | ||
char query[sizeof("START SLAVE ''") + NAME_CHAR_LEN]; | ||
DBUG_PRINT("info", ("Connection: '%.*s'", NAME_CHAR_LEN, stopped_replica)); | ||
// if SLAVE SQL is running, start it anyway to warn unexpected state change |
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.
The program runs SHOW SLAVE STATUS multiple times thoughout the various step functions:
do_show_slave_status
do_stop_slave_sql
do_start_slave_sql
(before this PR)
Perhaps the intent is in case replication configs change in the middle of mariadb-dump
?
@@ -0,0 +1,42 @@ | |||
# Interactions with --dump-slave; based on `main.rpl_mysqldump_slave` |
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.
and multi_source.gtid_slave_pos
for the setup
When pausing replicas for `mariadb-dump --dump-slave`, store the names of replicas paused in a dynamically-`malloc`ed buffer; use that (instead of a new SHOW _SLAVE_ STATUS) to resume replicas when the program ends. When making a dump with --dump-slave option, upon completion mysqldump starts slave threads even if they were not stopped by mysqldump itself. This behavior breaks delayed/manually synchronized slaves which have not to be running all the time. ⸺ MDEV-7611 Co-authored-by: Max Samoilenko <[email protected]>
--exec $MYSQL_DUMP_SLAVE --dump-slave --gtid mysql gtid_slave_pos > $MYSQLTEST_VARDIR/tmp/dump_2.sql | ||
--source include/stop_slave.inc |
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.
This test was aware 😄.
Description
When pausing replicas for
mariadb-dump --dump-slave
, store the names of replicas paused in a dynamically-malloc
ed buffer;use that (instead of a new SHOW SLAVE STATUS) to resume replicas when the program ends.
What problem is the patch trying to solve?
Release Notes
mariadb-dump --dump-slave
now only restarts replicas paused by it.How can this PR be tested?
multi_source.mariadb-dump_slave
tests this issue for both single- and multi-source replication.main.mysqldump
.Basing the PR against the correct MariaDB version
main
branch.PR quality check