diff options
-rw-r--r-- | mysql-test/r/events_restart.result | 27 | ||||
-rw-r--r-- | mysql-test/t/events_restart.test | 31 | ||||
-rw-r--r-- | sql/events.cc | 8 |
3 files changed, 62 insertions, 4 deletions
diff --git a/mysql-test/r/events_restart.result b/mysql-test/r/events_restart.result index e22cfa011f2..ab90f7ff2f7 100644 --- a/mysql-test/r/events_restart.result +++ b/mysql-test/r/events_restart.result @@ -110,3 +110,30 @@ Db Name Definer Time zone Type Execute at Interval value Interval field Starts E test e1 root@localhost SYSTEM RECURRING # 1 SECOND # # DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci DROP EVENT e1; # end test for bug#11748899 +# +# Test for MDEV-21758 Events switched randomly to SLAVESIDE_DISABLED +# +create event ev on schedule every 1 minute do set @a= 1; +select name, originator, status from mysql.event; +name originator status +ev 1 ENABLED +# +# Restarting server with server_id=100 +# +select @@global.server_id; +@@global.server_id +100 +select name, originator, status from mysql.event; +name originator status +ev 1 ENABLED +set global server_id= 1; +# +# Restarting server with the original server_id=1 +# +select @@global.server_id; +@@global.server_id +1 +select name, originator, status from mysql.event; +name originator status +ev 1 ENABLED +drop event ev; diff --git a/mysql-test/t/events_restart.test b/mysql-test/t/events_restart.test index ca674170e96..f56bd32b71d 100644 --- a/mysql-test/t/events_restart.test +++ b/mysql-test/t/events_restart.test @@ -141,3 +141,34 @@ SHOW EVENTS; DROP EVENT e1; --echo # end test for bug#11748899 + +--echo # +--echo # Test for MDEV-21758 Events switched randomly to SLAVESIDE_DISABLED +--echo # + +create event ev on schedule every 1 minute do set @a= 1; +select name, originator, status from mysql.event; + +--let $server_id= `SELECT @@global.server_id` + +--echo # +--echo # Restarting server with server_id=100 +--echo # +--let $restart_parameters= --server-id=100 +--source include/restart_mysqld.inc + +select @@global.server_id; +select name, originator, status from mysql.event; +--eval set global server_id= $server_id + +--echo # +--echo # Restarting server with the original server_id=$server_id +--echo # +--let $restart_parameters= +--source include/restart_mysqld.inc + +select @@global.server_id; +select name, originator, status from mysql.event; + +# Cleanup +drop event ev; diff --git a/sql/events.cc b/sql/events.cc index c189354d5eb..c5dc51ab83d 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -1201,9 +1201,9 @@ Events::load_events_from_db(THD *thd) #ifdef WITH_WSREP /** - IF SST is done from a galera node that is also acting as MASTER - newly synced node in galera eco-system will also copy-over the event state - enabling duplicate event in galera eco-system. + If SST is done from a galera node that is also acting as MASTER + newly synced node in galera eco-system will also copy-over the + event state enabling duplicate event in galera eco-system. DISABLE such events if the current node is not event orginator. (Also, make sure you skip disabling it if is already disabled to avoid creation of redundant action) @@ -1213,7 +1213,7 @@ Events::load_events_from_db(THD *thd) Infact, based on galera use-case it seems like it recommends to have each node with different server-id. */ - if (et->originator != thd->variables.server_id) + if (WSREP(thd) && et->originator != thd->variables.server_id) { if (et->status == Event_parse_data::SLAVESIDE_DISABLED) continue; |