#At file:///export/home/x/mysql-trunk-insert_delayed_valgrind/ based on revid:tatjana.nuernberg@stripped
3368 Jon Olav Hauglid 2011-05-12
Bug#12538873 BINLOG.BINLOG_STM_BINLOG FAILS IN VALGRIND
DUE TO INSERT DELAYED
The problem was that not all allocated memory was freed
when INSERT DELAYED was used with binlogging on.
When an instance of the Delayed_insert class is made, it's
query string is set to a copy of the table name. The same
string is also used for Delayed_insert's TABLE_LIST. The string
is later freed in Delayed_insert's destructor. The problem
was that the pointer to this string was overwritten during
INSERT DELAYED processing if binlogging was on. This caused
the original query string to never be freed which caused the
Valgrind warning. This was a regression introduced by WL#4033.
This patch fixes the problem by changing the Delayed_insert's
destructor to instead free the string using the pointer from
Delayed_insert's TABLE_LIST.
No test case added since the problem is already covered by
binlog.binlog_stm_binlog.test running with Valgrind.
modified:
sql/sql_insert.cc
=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc 2011-05-04 07:51:15 +0000
+++ b/sql/sql_insert.cc 2011-05-12 07:49:56 +0000
@@ -1948,7 +1948,7 @@ public:
mysql_cond_destroy(&cond);
mysql_cond_destroy(&cond_client);
thd.unlink(); // Must be unlinked under lock
- my_free(thd.query());
+ my_free(table_list.table_name);
thd.security_ctx->user= thd.security_ctx->host=0;
thread_count--;
delayed_insert_threads--;
@@ -2090,20 +2090,19 @@ bool delayed_get_table(THD *thd, MDL_req
mysql_mutex_lock(&LOCK_thread_count);
thread_count++;
mysql_mutex_unlock(&LOCK_thread_count);
+ di->table_list= *table_list; // Needed to open table
+ /* Replace volatile strings with local copies */
di->thd.set_db(table_list->db, (uint) strlen(table_list->db));
- di->thd.set_query(my_strdup(table_list->table_name,
- MYF(MY_WME | ME_FATALERROR)),
- 0, system_charset_info);
+ di->table_list.alias= di->table_list.table_name=
+ my_strdup(table_list->table_name, MYF(MY_WME | ME_FATALERROR));
+ di->table_list.db= di->thd.db;
+ di->thd.set_query(di->table_list.table_name, 0, system_charset_info);
if (di->thd.db == NULL || di->thd.query() == NULL)
{
/* The error is reported */
delete di;
goto end_create;
}
- di->table_list= *table_list; // Needed to open table
- /* Replace volatile strings with local copies */
- di->table_list.alias= di->table_list.table_name= di->thd.query();
- di->table_list.db= di->thd.db;
/* We need the tickets so that they can be cloned in handle_delayed_insert */
di->grl_protection.init(MDL_key::GLOBAL, "", "",
MDL_INTENTION_EXCLUSIVE, MDL_STATEMENT);
Attachment: [text/bzr-bundle] bzr/jon.hauglid@oracle.com-20110512074956-l74pfdv493fw8d3s.bundle
| Thread |
|---|
| • bzr commit into mysql-trunk branch (jon.hauglid:3368) Bug#12538873 | Jon Olav Hauglid | 12 May |