MDEV-34517: Memory leak on re-compilation of a failing statement inside a stored routine
SP instructions, consisting a body of a stored routine, had the same memory root as an instance of the class sp_head, representing abstraction for stored routine itself. It resulted in memory leaks on re-parsing a failed statement of a stored routine in case the statement re-compilation has to be performed by the reason of changes in metadata of tables, triggers, etc. the stored routine depends on. To fix this kind of memory leaks, every SP instruction requiring access to a LEX object must do re-parsing of a failed statement on its own memory root. These memory roots are allocated on sp_head's memory root and every instance of the sp_lex_instr class has a pointer to allocated memory root in case re-parsing of the correspondiong SP instruction was requested. On every subsequent re-parsing of the failed statement, a memory allocated on SP instruction's memory root is released and the memory root re-initialized. Following memory allocations taken place on re-parsing the SP instruction's statement is performed on the dedicated memory root. So, no memory leaks will happen on SP statement re-parsing.
Showing
Please register or sign in to comment