List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:May 12 2011 7:50am
Subject:bzr push into mysql-trunk branch (jon.hauglid:3367 to 3368) Bug#12538873
View as plain text  
 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
 3367 Tatjana Azundris Nuernberg	2011-05-12 [merge]
      manual merge

    added:
      mysql-test/include/start_slave_io.inc
      mysql-test/include/start_slave_sql.inc
    modified:
      .bzrignore
      BUILD/SETUP.sh
      client/mysql.cc*
      client/mysqlbinlog.cc
      client/mysqltest.cc
      extra/replace.c
      include/mysql.h
      include/mysql.h.pp
      libmysql/libmysql.c
      mysql-test/collections/default.experimental
      mysql-test/extra/rpl_tests/check_type.inc
      mysql-test/include/wait_show_condition.inc
      mysql-test/r/ctype_binary.result
      mysql-test/r/ctype_cp1251.result
      mysql-test/r/ctype_latin1.result
      mysql-test/r/ctype_ucs.result
      mysql-test/r/ctype_utf8.result
      mysql-test/r/distinct.result
      mysql-test/r/explain.result
      mysql-test/r/innodb_mysql_lock.result
      mysql-test/r/metadata.result
      mysql-test/r/mysqlbinlog_base64.result
      mysql-test/r/mysqldump.result
      mysql-test/r/trigger.result
      mysql-test/r/type_ranges.result
      mysql-test/r/variables-big.result
      mysql-test/suite/binlog/t/binlog_bug23533.test
      mysql-test/suite/funcs_1/r/is_columns_mysql.result
      mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result
      mysql-test/suite/rpl/r/rpl_crash_safe_master.result
      mysql-test/suite/rpl/r/rpl_row_crash_safe.result
      mysql-test/suite/rpl/r/rpl_row_ignorable_event.result
      mysql-test/suite/rpl/r/rpl_server_id2.result
      mysql-test/suite/rpl/r/rpl_show_slave_hosts.result
      mysql-test/suite/rpl/r/rpl_stm_mixed_crash_safe.result
      mysql-test/suite/rpl/r/rpl_typeconv.result
      mysql-test/suite/rpl/t/rpl_crash_safe_master.test
      mysql-test/suite/rpl/t/rpl_row_ignorable_event.test
      mysql-test/suite/rpl/t/rpl_row_until.test
      mysql-test/suite/rpl/t/rpl_server_id2.test
      mysql-test/suite/rpl/t/rpl_show_slave_hosts.test
      mysql-test/suite/rpl/t/rpl_typeconv.test
      mysql-test/t/distinct.test
      mysql-test/t/explain.test
      mysql-test/t/innodb_mysql_lock.test
      mysql-test/t/mysqlbinlog_base64.test
      mysql-test/t/mysqlbinlog_raw_mode.test
      mysql-test/t/mysqldump.test
      mysql-test/t/trigger.test
      mysql-test/t/variables-big.test
      scripts/make_win_bin_dist
      scripts/mysql_system_tables.sql
      sql/handler.h
      sql/item.cc
      sql/item_cmpfunc.cc
      sql/item_func.cc
      sql/item_row.cc
      sql/item_strfunc.cc
      sql/log_event.cc
      sql/my_decimal.cc
      sql/opt_range.cc
      sql/protocol.cc
      sql/rpl_slave.cc
      sql/sql_analyse.cc
      sql/sql_class.h
      sql/sql_lex.h
      sql/sql_partition.cc
      storage/archive/ha_archive.cc
      storage/ndb/src/kernel/blocks/lgman.cpp
      strings/decimal.c
      vio/viosocket.c
=== 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);

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (jon.hauglid:3367 to 3368) Bug#12538873Jon Olav Hauglid12 May