Skip to content

Commit

Permalink
MDEV-21758 : Events switched randomly to SLAVESIDE_DISABLED
Browse files Browse the repository at this point in the history
Change events only on Galera environment where idea is that
event is enabled only on one node of the cluster and nodes
are identified by server_id.
  • Loading branch information
Jan Lindström committed Mar 9, 2020
1 parent d7f7415 commit 2bf4e57
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 4 deletions.
27 changes: 27 additions & 0 deletions mysql-test/r/events_restart.result
Original file line number Diff line number Diff line change
Expand Up @@ -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;
31 changes: 31 additions & 0 deletions mysql-test/t/events_restart.test
Original file line number Diff line number Diff line change
Expand Up @@ -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;
8 changes: 4 additions & 4 deletions sql/events.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down

0 comments on commit 2bf4e57

Please sign in to comment.