-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MDEV-31636 Memory leak in Sys_var_gtid_binlog_state::do_check() #3523
base: 10.5
Are you sure you want to change the base?
Conversation
|
90eab64
to
98ebf41
Compare
sql/sys_vars.cc
Outdated
{ | ||
if (!var->save_result_exists) | ||
return; | ||
auto data= (gtid_binlog_state_data *)var->save_result.ptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ptr
is allocated in do_check()
somewhat quite surprisingly 'cos it all looks to me this could be done inside
`var->update().
I'd consider that first. If turns true indeed, we naturally shall carefully check all existing class' do_check()
(to my browsing there's none but ours replication's).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, though it logically makes sense for the actual validation of the input value to be in do_check()
. Sys_var_gtid_slave_pos
has a slightly different, yet still consistent to check
semantics pattern, which in Sys_var_gtid_slave_pos::do_check()
validates the value and saves the string on thd
, and then uses that string in Sys_var_gtid_slave_pos::global_update()
in a load. Can we follow that pattern here? (Though @DaveGosselin-MariaDB I recall in our discussion you mentioned trying to save something on the thread, and it not working. Is this what you tried?).
Generally speaking though, I' say whichever pattern we pick, Sys_var_gtid_binlog_state
and Sys_var_gtid_slave_pos
should probably follow the same pattern in the source code for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Brandon, I wasn't saving something on the thread but rather marking variables such that an on_error
phase could be executed over all affected variables so that they may handle any cleanup in their own implementation-dependent way (see 90eab64 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Dave for a good piece. It all seems to provide a solution. However let's look at the issue at a different angle I am suggesting in a note.
Thank you Andrei 😄 I will investigate the other angle. |
Move memory allocations performed during Sys_var_gtid_binlog_state::do_check to Sys_var_gtid_binlog_state::global_update where they will be freed before the latter method returns.
98ebf41
to
257a8e3
Compare
Move memory allocations performed during Sys_var_gtid_binlog_state::do_check to Sys_var_gtid_binlog_state::global_update where they will be freed before the latter method returns.