From 19e4ac2ead8da6da59db56ed76b7c6c2a96bba3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Tue, 14 May 2024 15:03:13 +0200 Subject: [PATCH] Mitigate invalid memory accesses from Monitor GR on 'SHUTDOWN SLOW' --- lib/MySQL_Monitor.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/MySQL_Monitor.cpp b/lib/MySQL_Monitor.cpp index a943f10a9..2d518109b 100644 --- a/lib/MySQL_Monitor.cpp +++ b/lib/MySQL_Monitor.cpp @@ -4091,6 +4091,14 @@ void* monitor_GR_thread_HG(void *arg) { // 3. Delegate the async fetching + actions of 'MySQL_Monitor_State_Data' with conns on 'Monitor_Poll'. /////////////////////////////////////////////////////////////////////////////////////// + // NOTE: This is just a best effort to avoid invalid memory accesses during 'SHUTDOWN SLOW'. Since the + // previous section is 'time consuming', there are good changes that we can detect a shutdown before + // trying to perform the monitoring actions on the acquired 'mmsd'. This exact scenario and timing has + // been previously observed in the CI. + if (GloMyMon->shutdown) { + break; + } + // Handle 'mmsds' that failed to optain conns for (const unique_ptr& mmsd : fail_mmsds) { async_gr_mon_actions_handler(mmsd.get());