Author: baolin.hbl Date: Fri Oct 28 09:18:46 2022 +0800 [Bugfix] [bug#107991] Clone_persist_gtid causes memory leak Problem: ======== This is a fix for bug#107991. Since MySQL8.0, the Clone_persist_gtid thread is responsible for saving GTID into dd table gtid_executed periodically (every 100ms). The Clone_persist_gtid thread requests memory from thd->mem_root during lock_tables. Because the thread will not be closed until shutdown, the memory will not be freed or reused. Solution: ========= Clear mem_root after each flush_gtids diff --git a/storage/innobase/clone/clone0repl.cc b/storage/innobase/clone/clone0repl.cc index 1d22a6814f4..db3488521e7 100644 --- a/storage/innobase/clone/clone0repl.cc +++ b/storage/innobase/clone/clone0repl.cc @@ -607,6 +607,7 @@ void Clone_persist_gtid::periodic_write() { os_event_reset(m_event); /* Write accumulated GTIDs to disk table */ flush_gtids(thd); + thd->mem_root->ClearForReuse(); }