Details
-
New Feature
-
Status: Stalled (View Workflow)
-
Major
-
Resolution: Unresolved
Description
When I create an event on the master it is replicated to the slave BUT it is set to 'DISABLE ON SLAVE' there and thus not executed on slave. This is documented and fine so far.
DELIMITER //
|
|
CREATE OR REPLACE DEFINER = `dbstat`@`localhost` EVENT purge_table_size |
ON SCHEDULE EVERY 5 MINUTE |
ENABLE
|
DO
|
BEGIN
|
DO 'nothing'; |
END; |
//
|
|
DELIMITER ;
|
|
SELECT db, name, definer, execute_at, CONCAT(interval_value, ' ', interval_field) AS 'interval' |
, created, modified, last_executed, starts, ends, status, on_completion
|
FROM mysql.event |
ORDER BY db, name ASC |
;
|
+------+------------------+------------------+------------+----------+---------------------+---------------------+---------------+---------------------+------+--------------------+---------------+
|
| db | name | definer | execute_at | interval | created | modified | last_executed | starts | ends | status | on_completion |
|
+------+------------------+------------------+------------+----------+---------------------+---------------------+---------------+---------------------+------+--------------------+---------------+
|
| test | purge_table_size | dbstat@localhost | NULL | 5 MINUTE | 2024-03-27 17:03:50 | 2024-03-27 17:03:50 | NULL | 2024-03-27 16:03:50 | NULL | SLAVESIDE_DISABLED | DROP |
|
+------+------------------+------------------+------------+----------+---------------------+---------------------+---------------+---------------------+------+--------------------+---------------+
|
But in some cases one wants to have the events also enabled on the slave.
In this case I have to enable the event on the slave as well with:
ALTER EVENT event_name ENABLE; |
This has now 2 problems:
1.) Whenever I REPLACE the event on Master I have to think about to re-enable the event on the slave again. This can lead to errors and is not idempotent/reentrant. So I can hardly do this automatized...
2.) In a Master/Master topology, when I run the ALTER EVENT ... ENABLE on the passive Master it will deactivate the event on the active Master again. So I have to work with sql_log_bin = off which is also dangerous. So not idempotent/reentrant as well.
So we have some problems in this situation which are dangerous for production systems...
My suggestion is to add a new functionality: ENDABLE ON SLAVE which does the opposite of DISABLE ON SLAVE: It enables the event on master AND slave.
Thanks, Oli. This makes sense, IIUC the event is populating local tables with data about the local instance. I assume the event sets sql_log_bin=0 or something to not replicate its dbstat tables.
So in this case, indeed it seems a property of the event (and the decision of the event developer) that it is something that wants to be active also on the slaves.
On the other hand, installing a monitoring tool on a server is not something I normally would expect to use MariaDB replication for? It is not clear to me why you mentioned it as risky to install the dbstat separately on each server with sql_log_bin = off. Still, this is always a difficult line to draw when using things like stored procedures, events, etc. in SQL databases, when something is part of the data, and when it is part of the software deployment.