From 9937d5f0a91bb8fdceb7d2110e22c03878242a29 Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Tue, 29 Nov 2011 20:17:02 +0200 Subject: Bug#13437900 - VALGRIND REPORTS A LEAK FOR REPL_IGNORE_SERVER_IDS There was memory leak when running some tests on PB2. The reason of the failure is an early return from change_master() that was supposed to deallocate a dyn-array. Fixed with relocating the dyn-array's destructor at ~LEX() that is the end of the session, per Gleb's patch idea. Two optimizations were done: the static buffer for the dyn-array to base on, and the array initialization is called precisely when it's necessary rather than per each CHANGE-MASTER as before. --- sql/sql_lex.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sql/sql_lex.h') diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 542e8b42ae2..474fa87495b 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -291,7 +291,9 @@ typedef struct st_lex_master_info char *ssl_key, *ssl_cert, *ssl_ca, *ssl_capath, *ssl_cipher; char *relay_log_name; ulong relay_log_pos; + bool repl_ignore_server_ids_inited; DYNAMIC_ARRAY repl_ignore_server_ids; + typeof(::server_id) repl_ignore_server_ids_static_buffer[4]; } LEX_MASTER_INFO; typedef struct st_lex_reset_slave @@ -2455,6 +2457,11 @@ struct LEX: public Query_tables_list destroy_query_tables_list(); plugin_unlock_list(NULL, (plugin_ref *)plugins.buffer, plugins.elements); delete_dynamic(&plugins); + if (mi.repl_ignore_server_ids_inited) + { + delete_dynamic(&mi.repl_ignore_server_ids); + mi.repl_ignore_server_ids_inited= false; + } } inline bool is_ps_or_view_context_analysis() -- cgit v1.2.1