Hello Claudio,

This boils down to the bug that we had filed 2 years ago. I went through that ticket and it says that the issue has been fixed in maxscale 2.3. However, I just verified it and it doesn't seem to work on maxscale 2.3 as well.

Old ticket number: CS0088452

https://jira.mariadb.org/browse/MXS-1937

=============================
-- Testing with maxscale 2.3.17
=============================

The event remains as enabled when the master becomes slave and it remains as slave_disabled on the new master. This is creating data conflicts as the event get executed on the slave node.

==============
-- On Master
==============
MariaDB [dummydb]> CREATE EVENT writeIntoDemo
-> ON SCHEDULE EVERY 1 MINUTE
-> STARTS CURRENT_TIMESTAMP + INTERVAL 1 MINUTE
-> ENDS CURRENT_TIMESTAMP + INTERVAL 1 HOUR
-> DO insert into dummydb.demo(date_var) values(now());
Query OK, 0 rows affected (0.001 sec)MariaDB [dummydb]> show events
-> ;
+---------+---------------+----------------+-----------+-----------+------------+----------------+----------------+---------------------+---------------------+---------+------------+----------------------+----------------------+--------------------+
| Db | Name | Definer | Time zone | Type | Execute at | Interval value | Interval field | Starts | Ends | Status | Originator | character_set_client | collation_connection | Database Collation |
+---------+---------------+----------------+-----------+-----------+------------+----------------+----------------+---------------------+---------------------+---------+------------+----------------------+----------------------+--------------------+
| dummydb | writeIntoDemo | root@localhost | SYSTEM | RECURRING | NULL | 1 | MINUTE | 2020-09-07 15:55:47 | 2020-09-07 16:54:47 | ENABLED | 110447958 | latin1 | latin1_swedish_ci | utf8_general_ci |
+---------+---------------+----------------+-----------+-----------+------------+----------------+----------------+---------------------+---------------------+---------+------------+----------------------+----------------------+--------------------+
1 row in set (0.002 sec)

MariaDB [dummydb]> select * from demo;
Empty set (0.000 sec)

MariaDB [dummydb]>
MariaDB [dummydb]>
MariaDB [dummydb]>
MariaDB [dummydb]>
MariaDB [dummydb]> select * from demo;
+----+---------------------+
| id | date_var |
+----+---------------------+
| 1 | 2020-09-07 15:55:47 |
+----+---------------------+
1 row in set (0.000 sec)

MariaDB [dummydb]>


==============
-- On Slave
==============

MariaDB [dummydb]> select * from demo;
+----+---------------------+
| id | date_var |
+----+---------------------+
| 1 | 2020-09-07 15:55:47 |
+----+---------------------+
1 row in set (0.000 sec)

MariaDB [dummydb]> show events
-> ;
+---------+---------------+----------------+-----------+-----------+------------+----------------+----------------+---------------------+---------------------+--------------------+------------+----------------------+----------------------+--------------------+
| Db | Name | Definer | Time zone | Type | Execute at | Interval value | Interval field | Starts | Ends | Status | Originator | character_set_client | collation_connection | Database Collation |
+---------+---------------+----------------+-----------+-----------+------------+----------------+----------------+---------------------+---------------------+--------------------+------------+----------------------+----------------------+--------------------+
| dummydb | writeIntoDemo | root@localhost | SYSTEM | RECURRING | NULL | 1 | MINUTE | 2020-09-07 15:55:47 | 2020-09-07 16:54:47 | SLAVESIDE_DISABLED | 110447958 | latin1 | latin1_swedish_ci | utf8_general_ci |
+---------+---------------+----------------+-----------+-----------+------------+----------------+----------------+---------------------+---------------------+--------------------+------------+----------------------+----------------------+--------------------+
1 row in set (0.002 sec)MariaDB [dummydb]>


============================
-- switch master from mdb-dc1-cmdb-mariadb-0 to mdb-dc1-cmdb-mariadb-1 :
============================

[root@bcmt-dba-control-01 ~]# kubectl exec mdb-dc1-cmdb-maxscale-0 maxctrl list servers
Defaulting container name to maxscale.
Use 'kubectl describe pod/mdb-dc1-cmdb-maxscale-0 -n default' to see all of the containers in this pod.
┌────────────────────────┬───────────────┬──────┬─────────────┬─────────────────┬───────────────┐
│ Server │ Address │ Port │ Connections │ State │ GTID │
├────────────────────────┼───────────────┼──────┼─────────────┼─────────────────┼───────────────┤
│ mdb-dc1-cmdb-mariadb-1 │ 192.168.1.114 │ 3306 │ 0 │ Master, Running │ 0-110447958-9 │
├────────────────────────┼───────────────┼──────┼─────────────┼─────────────────┼───────────────┤
│ mdb-dc1-cmdb-mariadb-0 │ 192.168.1.207 │ 3306 │ 0 │ Down │ 0-110447958-9 │
├────────────────────────┼───────────────┼──────┼─────────────┼─────────────────┼───────────────┤
│ mdb-dc1-cmdb-mariadb-2 │ 192.168.1.15 │ 3306 │ 0 │ Slave, Running │ 0-110447958-9 │
└────────────────────────┴───────────────┴──────┴─────────────┴─────────────────┴───────────────┘

[root@bcmt-dba-control-01 cmdb]# kubectl exec mdb-dc1-cmdb-maxscale-0 maxctrl list servers
Defaulting container name to maxscale.
Use 'kubectl describe pod/mdb-dc1-cmdb-maxscale-0 -n default' to see all of the containers in this pod.
┌────────────────────────┬───────────────┬──────┬─────────────┬─────────────────┬───────────────┐
│ Server │ Address │ Port │ Connections │ State │ GTID │
├────────────────────────┼───────────────┼──────┼─────────────┼─────────────────┼───────────────┤
│ mdb-dc1-cmdb-mariadb-1 │ 192.168.1.114 │ 3306 │ 0 │ Master, Running │ 0-110447958-9 │
├────────────────────────┼───────────────┼──────┼─────────────┼─────────────────┼───────────────┤
│ mdb-dc1-cmdb-mariadb-0 │ 192.168.1.219 │ 3306 │ 0 │ Slave, Running │ 0-110447958-9 │
├────────────────────────┼───────────────┼──────┼─────────────┼─────────────────┼───────────────┤
│ mdb-dc1-cmdb-mariadb-2 │ 192.168.1.15 │ 3306 │ 0 │ Slave, Running │ 0-110447958-9 │
└────────────────────────┴───────────────┴──────┴─────────────┴─────────────────┴───────────────┘
[root@bcmt-dba-control-01 cmdb]#

============================
-- On mdb-dc1-cmdb-mariadb-1 (new master):
============================
-- The event status has not changed.MariaDB [dummydb]> show events;
+---------+---------------+----------------+-----------+-----------+------------+----------------+----------------+---------------------+---------------------+--------------------+------------+----------------------+----------------------+--------------------+
| Db | Name | Definer | Time zone | Type | Execute at | Interval value | Interval field | Starts | Ends | Status | Originator | character_set_client | collation_connection | Database Collation |
+---------+---------------+----------------+-----------+-----------+------------+----------------+----------------+---------------------+---------------------+--------------------+------------+----------------------+----------------------+--------------------+
| dummydb | writeIntoDemo | root@localhost | SYSTEM | RECURRING | NULL | 1 | MINUTE | 2020-09-07 15:55:47 | 2020-09-07 16:54:47 | SLAVESIDE_DISABLED | 110447958 | latin1 | latin1_swedish_ci | utf8_general_ci |
+---------+---------------+----------------+-----------+-----------+------------+----------------+----------------+---------------------+---------------------+--------------------+------------+----------------------+----------------------+--------------------+
1 row in set (0.001 sec)MariaDB [dummydb]>

==========================================
-- On mdb-dc1-cmdb-mariadb-0 (old master):MariaDB [dummydb]> show events;
==========================================

+---------+---------------+----------------+-----------+-----------+------------+----------------+----------------+---------------------+---------------------+---------+------------+----------------------+----------------------+--------------------+
| Db | Name | Definer | Time zone | Type | Execute at | Interval value | Interval field | Starts | Ends | Status | Originator | character_set_client | collation_connection | Database Collation |
+---------+---------------+----------------+-----------+-----------+------------+----------------+----------------+---------------------+---------------------+---------+------------+----------------------+----------------------+--------------------+
| dummydb | writeIntoDemo | root@localhost | SYSTEM | RECURRING | NULL | 1 | MINUTE | 2020-09-07 15:55:47 | 2020-09-07 16:54:47 | ENABLED | 110447958 | latin1 | latin1_swedish_ci | utf8_general_ci |
+---------+---------------+----------------+-----------+-----------+------------+----------------+----------------+---------------------+---------------------+---------+------------+----------------------+----------------------+--------------------+
1 row in set (0.001 sec)MariaDB [dummydb]>
