Skip to content

Commit 64e1dda

Browse files
sjaakolavuvova
authored andcommitted
MW-416 DDL replication moved after acl checking
galera_events test shows a regression with the original fix for MW-416 Reason was that Events::drop_event() can be called also from inside event execution, and there we have a speacial treatment for event, which executes "DROP EVENT" statement, and runs TOI replication inside the event processing body. This resulted in executing WSREP_TO_ISOLATION two times for such DROP EVENT statement. Fix is to call WSREP_TO_ISOLATION_BEGIN only in Events::drop_event()
1 parent 1a8da00 commit 64e1dda

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

sql/event_data_objects.cc

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,19 +1472,33 @@ Event_job_data::execute(THD *thd, bool drop)
14721472
bool save_tx_read_only= thd->tx_read_only;
14731473
thd->tx_read_only= false;
14741474

1475-
if (WSREP(thd))
1476-
{
1475+
/*
1476+
This code is processing event execution and does not have client
1477+
connection. Here, event execution will now execute a prepared
1478+
DROP EVENT statement, but thd->lex->sql_command is set to
1479+
SQLCOM_CREATE_PROCEDURE
1480+
DROP EVENT will be logged in binlog, and we have to
1481+
replicate it to make all nodes have consistent event definitions
1482+
Wsrep DDL replication is triggered inside Events::drop_event(),
1483+
and here we need to prepare the THD so that DDL replication is
1484+
possible, essentially it requires setting sql_command to
1485+
SQLCOMM_DROP_EVENT, we will switch sql_command for the duration
1486+
of DDL replication only.
1487+
*/
1488+
const enum_sql_command sql_command_save= thd->lex->sql_command;
1489+
const bool sql_command_set= WSREP(thd);
1490+
1491+
if (sql_command_set)
14771492
thd->lex->sql_command = SQLCOM_DROP_EVENT;
1478-
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL);
1479-
}
14801493

14811494
ret= Events::drop_event(thd, dbname, name, FALSE);
14821495

1483-
WSREP_TO_ISOLATION_END;
1496+
if (sql_command_set)
1497+
{
1498+
WSREP_TO_ISOLATION_END;
1499+
thd->lex->sql_command = sql_command_save;
1500+
}
14841501

1485-
#ifdef WITH_WSREP
1486-
error:
1487-
#endif
14881502
thd->tx_read_only= save_tx_read_only;
14891503
thd->security_ctx->master_access= saved_master_access;
14901504
}

0 commit comments

Comments
 (0)