Skip to content
/ server Public

Commit 0db178d

Browse files
committed
MDEV-38124 event scheduler spams the error log
event scheduler was printing a lot of info in [Note] in error log. change to print its startup/shutdown notes only when log_warnings>0. and runtime notes only when log_warnings>2. one note was an abnormal error, change to [Error].
1 parent c26d7b9 commit 0db178d

File tree

3 files changed

+25
-21
lines changed

3 files changed

+25
-21
lines changed

sql/event_data_objects.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,8 +1476,9 @@ Event_job_data::execute(THD *thd, bool drop)
14761476
We must do it here since here we're under the right authentication
14771477
ID of the event definer.
14781478
*/
1479-
sql_print_information("Event Scheduler: Dropping %s.%s",
1480-
(const char *) dbname.str, (const char *) name.str);
1479+
if (global_system_variables.log_warnings > 2)
1480+
sql_print_information("Event Scheduler: Dropping %s.%s",
1481+
dbname.str, name.str);
14811482
/*
14821483
Construct a query for the binary log, to ensure the event is dropped
14831484
on the slave

sql/event_queue.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ Event_queue::empty_queue()
517517
DBUG_ENTER("Event_queue::empty_queue");
518518
DBUG_PRINT("enter", ("Purging the queue. %u element(s)", queue.elements));
519519

520-
if (queue.elements)
520+
if (queue.elements && global_system_variables.log_warnings > 2)
521521
sql_print_information("Event Scheduler: Purging the queue. %u events",
522522
queue.elements);
523523
/* empty the queue */
@@ -668,9 +668,10 @@ Event_queue::get_top_for_execution_if_time(THD *thd,
668668
if (top->status == Event_parse_data::DISABLED)
669669
{
670670
DBUG_PRINT("info", ("removing from the queue"));
671-
sql_print_information("Event Scheduler: Last execution of %s.%s. %s",
672-
top->dbname.str, top->name.str,
673-
top->dropped? "Dropping.":"");
671+
if (global_system_variables.log_warnings > 2)
672+
sql_print_information("Event Scheduler: Last execution of %s.%s. %s",
673+
top->dbname.str, top->name.str,
674+
top->dropped? "Dropping.":"");
674675
delete top;
675676
queue_remove_top(&queue);
676677
}

sql/event_scheduler.cc

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,9 @@ Event_worker_thread::run(THD *thd, Event_queue_element_for_exec *event)
319319

320320
print_warnings(thd, &job_data);
321321

322-
if (res)
323-
sql_print_information("Event Scheduler: "
324-
"[%s].[%s.%s] event execution failed.",
325-
job_data.definer.str,
322+
if (res && global_system_variables.log_warnings > 2)
323+
sql_print_information("Event Scheduler: [%s].[%s.%s] event execution "
324+
"failed.", job_data.definer.str,
326325
job_data.dbname.str, job_data.name.str);
327326
end:
328327
#ifdef HAVE_PSI_STATEMENT_INTERFACE
@@ -471,8 +470,9 @@ Event_scheduler::run(THD *thd)
471470
int res= FALSE;
472471
DBUG_ENTER("Event_scheduler::run");
473472

474-
sql_print_information("Event Scheduler: scheduler thread started with id %lu",
475-
(ulong) thd->thread_id);
473+
if (global_system_variables.log_warnings)
474+
sql_print_information("Event Scheduler: scheduler thread started with "
475+
"id %llu", (ulonglong) thd->thread_id);
476476
/*
477477
Recalculate the values in the queue because there could have been stops
478478
in executions of the scheduler and some times could have passed by.
@@ -486,9 +486,8 @@ Event_scheduler::run(THD *thd)
486486
/* Gets a minimized version */
487487
if (queue->get_top_for_execution_if_time(thd, &event_name))
488488
{
489-
sql_print_information("Event Scheduler: "
490-
"Serious error during getting next "
491-
"event to execute. Stopping");
489+
sql_print_error("Event Scheduler: Serious error during getting next "
490+
"event to execute. Stopping");
492491
break;
493492
}
494493

@@ -660,14 +659,16 @@ Event_scheduler::stop()
660659
DBUG_PRINT("info", ("Scheduler thread has id %lu",
661660
(ulong) scheduler_thd->thread_id));
662661
/* This will wake up the thread if it waits on Queue's conditional */
663-
sql_print_information("Event Scheduler: Killing the scheduler thread, "
664-
"thread id %lu",
665-
(ulong) scheduler_thd->thread_id);
662+
if (global_system_variables.log_warnings)
663+
sql_print_information("Event Scheduler: Killing the scheduler thread, "
664+
"thread id %llu",
665+
(ulonglong) scheduler_thd->thread_id);
666666
scheduler_thd->awake(KILL_CONNECTION);
667667

668668
/* thd could be 0x0, when shutting down */
669-
sql_print_information("Event Scheduler: "
670-
"Waiting for the scheduler thread to reply");
669+
if (global_system_variables.log_warnings > 1)
670+
sql_print_information("Event Scheduler: "
671+
"Waiting for the scheduler thread to reply");
671672

672673
/*
673674
Wait only 2 seconds, as there is a small chance the thread missed the
@@ -678,7 +679,8 @@ Event_scheduler::stop()
678679
COND_STATE_WAIT(thd, &top_time, &stage_waiting_for_scheduler_to_stop);
679680
} while (state == STOPPING);
680681
DBUG_PRINT("info", ("Scheduler thread has cleaned up. Set state to INIT"));
681-
sql_print_information("Event Scheduler: Stopped");
682+
if (global_system_variables.log_warnings)
683+
sql_print_information("Event Scheduler: Stopped");
682684
end:
683685
UNLOCK_DATA();
684686
DBUG_RETURN(FALSE);

0 commit comments

Comments
 (0)