-
-
Notifications
You must be signed in to change notification settings - Fork 2k
MDEV-7394 : Making slave_skip_errors writable at runtime when slave is stopped #4634
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # MDEV-7394 test dynamic slave_skip_errors (writable when slaves stopped) | ||
| include/master-slave.inc | ||
| [connection master] | ||
| connection slave; | ||
| STOP SLAVE; | ||
| SET GLOBAL slave_skip_errors = "1062"; | ||
| START SLAVE; | ||
| SELECT @@global.slave_skip_errors; | ||
| @@global.slave_skip_errors | ||
| 1062 | ||
| connection master; | ||
| CREATE TABLE t1 (id INT PRIMARY KEY); | ||
| include/sync_slave_sql_with_master.inc | ||
| connection slave; | ||
| INSERT INTO t1 VALUES (2); | ||
| connection master; | ||
| INSERT INTO t1 VALUES (2); | ||
| include/sync_slave_sql_with_master.inc | ||
| connection slave; | ||
| include/check_slave_is_running.inc | ||
| START SLAVE; | ||
| Warnings: | ||
| Note 1254 Slave is already running | ||
| include/wait_for_slave_to_start.inc | ||
| SET GLOBAL slave_skip_errors = "1062"; | ||
| ERROR HY000: This operation cannot be performed as you have a running slave ''; run STOP SLAVE '' first | ||
| STOP SLAVE; | ||
| SET GLOBAL slave_skip_errors = "1050,1004,1104,1146"; | ||
| START SLAVE; | ||
| # erros should be showed in sorted order | ||
| SELECT @@global.slave_skip_errors; | ||
| @@global.slave_skip_errors | ||
| 1004,1050,1104,1146 | ||
| SET GLOBAL slave_ddl_exec_mode = STRICT; | ||
| # test that mulitiple errors are set correctly | ||
| connection slave; | ||
| include/stop_slave.inc | ||
| CREATE TABLE t2 (id INT); | ||
| include/start_slave.inc | ||
| connection master; | ||
| CREATE TABLE t2 (id INT); | ||
| INSERT INTO t1 VALUES (4); | ||
| connection slave; | ||
| connection slave; | ||
| include/check_slave_is_running.inc | ||
| connection master; | ||
| INSERT INTO t1 VALUES (3); | ||
| include/sync_slave_sql_with_master.inc | ||
| connection slave; | ||
| SELECT COUNT(*) FROM t1 WHERE id=3; | ||
| COUNT(*) | ||
| 1 | ||
| STOP SLAVE; | ||
| SET GLOBAL slave_skip_errors = "OFF"; | ||
| START SLAVE; | ||
| connection master; | ||
| DROP TABLE t1; | ||
| DROP TABLE t2; | ||
| include/sync_slave_sql_with_master.inc | ||
| connection slave; | ||
| SET GLOBAL slave_ddl_exec_mode = DEFAULT; | ||
| include/rpl_end.inc |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| --echo # MDEV-7394 test dynamic slave_skip_errors (writable when slaves stopped) | ||
|
|
||
| --source include/master-slave.inc | ||
| connection slave; | ||
| STOP SLAVE; | ||
| SET GLOBAL slave_skip_errors = "1062"; | ||
| START SLAVE; | ||
| SELECT @@global.slave_skip_errors; | ||
|
|
||
| connection master; | ||
| CREATE TABLE t1 (id INT PRIMARY KEY); | ||
| --source include/sync_slave_sql_with_master.inc | ||
|
|
||
| connection slave; | ||
| INSERT INTO t1 VALUES (2); | ||
|
|
||
| connection master; | ||
| INSERT INTO t1 VALUES (2); | ||
| --source include/sync_slave_sql_with_master.inc | ||
|
|
||
| connection slave; | ||
| source include/check_slave_is_running.inc; | ||
| START SLAVE; | ||
| --source include/wait_for_slave_to_start.inc | ||
| --error ER_SLAVE_MUST_STOP | ||
| SET GLOBAL slave_skip_errors = "1062"; | ||
|
|
||
| STOP SLAVE; | ||
| SET GLOBAL slave_skip_errors = "1050,1004,1104,1146"; | ||
| START SLAVE; | ||
|
|
||
| --echo # erros should be showed in sorted order | ||
| SELECT @@global.slave_skip_errors; | ||
|
|
||
| SET GLOBAL slave_ddl_exec_mode = STRICT; | ||
| --echo # test that mulitiple errors are set correctly | ||
|
|
||
| connection slave; | ||
| --source include/stop_slave.inc | ||
| CREATE TABLE t2 (id INT); | ||
| --source include/start_slave.inc | ||
|
|
||
| connection master; | ||
| CREATE TABLE t2 (id INT); | ||
| INSERT INTO t1 VALUES (4); | ||
| sync_slave_with_master; | ||
|
|
||
| connection slave; | ||
| source include/check_slave_is_running.inc; | ||
|
|
||
| connection master; | ||
| INSERT INTO t1 VALUES (3); | ||
| --source include/sync_slave_sql_with_master.inc | ||
|
|
||
| connection slave; | ||
| SELECT COUNT(*) FROM t1 WHERE id=3; | ||
|
|
||
| STOP SLAVE; | ||
| SET GLOBAL slave_skip_errors = "OFF"; | ||
| START SLAVE; | ||
|
|
||
| connection master; | ||
| DROP TABLE t1; | ||
| DROP TABLE t2; | ||
| --source include/sync_slave_sql_with_master.inc | ||
| connection slave; | ||
| SET GLOBAL slave_ddl_exec_mode = DEFAULT; | ||
|
|
||
| --source include/rpl_end.inc |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6212,12 +6212,57 @@ static Sys_var_multi_source_ulonglong Sys_max_relay_log_size( | |
| VALID_RANGE(0, 1024L*1024*1024), DEFAULT(0), BLOCK_SIZE(IO_SIZE), | ||
| ON_UPDATE(update_max_relay_log_size)); | ||
|
|
||
| bool check_slave_skip_errors(sys_var *self, THD *thd, set_var *var) | ||
| { | ||
| return give_error_if_slave_running(0); | ||
| } | ||
|
|
||
| bool update_slave_skip_errors(sys_var *self, THD *thd, enum_var_type type) | ||
| { | ||
| bool err= false; | ||
| mysql_mutex_unlock(&LOCK_global_system_variables); | ||
| mysql_mutex_lock(&LOCK_active_mi); | ||
|
|
||
| if (give_error_if_slave_running(1)) | ||
| { | ||
| my_error(ER_SLAVE_MUST_STOP, MYF(0)); | ||
| err= true; | ||
| } | ||
| if (!err) | ||
| { | ||
| if (init_slave_skip_errors_bitmap(opt_slave_skip_errors)) | ||
| { | ||
| my_error(ER_OUT_OF_RESOURCES, MYF(0)); | ||
| err= true; | ||
| } | ||
| else | ||
| { | ||
| /* | ||
| * global_update() already ran my_memdup() on the user's string and stored | ||
| * the heap pointer in opt_slave_skip_errors with ALLOCATED set. | ||
| * We must call self->cleanup() after building the bitmap to free that | ||
| * heap allocation before make_slave_skip_errors_printable() overwrites | ||
| * opt_slave_skip_errors with the static slave_skip_error_names[] buffer. | ||
| * Without this, the heap pointer is lost (leak) and ALLOCATED stays set, | ||
| * causing a crash when cleanup() later tries to free the static buffer. | ||
| */ | ||
| self->cleanup(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a comment explaining why we need to manually call |
||
| make_slave_skip_errors_printable(); | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Many of the lines in this file have whitespace at the end. Please look at your changes with |
||
|
|
||
| mysql_mutex_unlock(&LOCK_active_mi); | ||
| mysql_mutex_lock(&LOCK_global_system_variables); | ||
| return err; | ||
| } | ||
| static Sys_var_charptr Sys_slave_skip_errors( | ||
| "slave_skip_errors", "Tells the slave thread to continue " | ||
| "replication when a query event returns an error from the " | ||
| "provided list", | ||
| READ_ONLY GLOBAL_VAR(opt_slave_skip_errors), CMD_LINE(REQUIRED_ARG), | ||
| DEFAULT(0)); | ||
| GLOBAL_VAR(opt_slave_skip_errors), CMD_LINE(REQUIRED_ARG), | ||
| DEFAULT(NULL), NO_MUTEX_GUARD, NOT_IN_BINLOG, | ||
| ON_CHECK(check_slave_skip_errors), | ||
| ON_UPDATE(update_slave_skip_errors)); | ||
|
|
||
| static Sys_var_on_access_global<Sys_var_ulonglong, | ||
| PRIV_SET_SYSTEM_GLOBAL_VAR_READ_BINLOG_SPEED_LIMIT> | ||
|
|
||
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.
Is this testing an additional path? Or just a reset?
If its just a reset, omit.
Either way, put the last line
set GLOBAL slave_skip_errors = @my_slave_skip_errors;here as its relevant to this test.Could put the first
set @my_slave_skip_errors =@@global.slave_skip_errors;just prior to this test block.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.
no it's not reset , I am saving the initial values in the beginning of the test , and resting in the end, but I will move those this block of test as you suggested