From e5a5573f782723e40c372f38346a60b1ccc644d6 Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 2 Nov 2023 11:49:03 +0200 Subject: [PATCH] rpl.rpl_invoked_features fails sporadically with "Duplicate key error" The reason was that Event e11 was re-executed before "ALTER EVENT e11 DISABLE" had been executed. Fixed by increasing re-schedule time Other things: - Removed double accounting of 'execution_count'. It was incremented in top->mark_last_executed(thd) that was executed a few lines earlier. --- mysql-test/suite/rpl/r/rpl_invoked_features.result | 4 ++-- mysql-test/suite/rpl/t/rpl_invoked_features.test | 9 ++++++--- sql/event_queue.cc | 1 - 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_invoked_features.result b/mysql-test/suite/rpl/r/rpl_invoked_features.result index 43a8e8625de..3cfd40d5a0e 100644 --- a/mysql-test/suite/rpl/r/rpl_invoked_features.result +++ b/mysql-test/suite/rpl/r/rpl_invoked_features.result @@ -45,14 +45,14 @@ BEGIN UPDATE t12 SET c = ''; UPDATE t13 SET c = ''; END| -CREATE EVENT e1 ON SCHEDULE EVERY 1 SECOND DISABLE DO +CREATE EVENT e1 ON SCHEDULE EVERY 10 SECOND DISABLE DO BEGIN ALTER EVENT e1 DISABLE; CALL p1(10, ''); END| Warnings: Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -CREATE EVENT e11 ON SCHEDULE EVERY 1 SECOND DISABLE DO +CREATE EVENT e11 ON SCHEDULE EVERY 10 SECOND DISABLE DO BEGIN ALTER EVENT e11 DISABLE; CALL p11(10, ''); diff --git a/mysql-test/suite/rpl/t/rpl_invoked_features.test b/mysql-test/suite/rpl/t/rpl_invoked_features.test index 91391cf8372..cd2b770c419 100644 --- a/mysql-test/suite/rpl/t/rpl_invoked_features.test +++ b/mysql-test/suite/rpl/t/rpl_invoked_features.test @@ -102,14 +102,17 @@ BEGIN UPDATE t13 SET c = ''; END| -# Create events which will run every 1 sec -CREATE EVENT e1 ON SCHEDULE EVERY 1 SECOND DISABLE DO +# Create events which will run every 10 sec +# It cannot be much shorter as we have to ensure that a new +# event is not scheduled before the DISABLE has been +# executed. +CREATE EVENT e1 ON SCHEDULE EVERY 10 SECOND DISABLE DO BEGIN ALTER EVENT e1 DISABLE; CALL p1(10, ''); END| -CREATE EVENT e11 ON SCHEDULE EVERY 1 SECOND DISABLE DO +CREATE EVENT e11 ON SCHEDULE EVERY 10 SECOND DISABLE DO BEGIN ALTER EVENT e11 DISABLE; CALL p11(10, ''); diff --git a/sql/event_queue.cc b/sql/event_queue.cc index 516bdc9158f..0298e7746ad 100644 --- a/sql/event_queue.cc +++ b/sql/event_queue.cc @@ -650,7 +650,6 @@ Event_queue::get_top_for_execution_if_time(THD *thd, top->status= Event_parse_data::DISABLED; DBUG_PRINT("info", ("event %s status is %d", top->name.str, top->status)); - top->execution_count++; (*event_name)->dropped= top->dropped; /* Save new values of last_executed timestamp and event status on stack