MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:August 13 2009 8:07pm
Subject:bzr commit into mysql-5.0-bugteam branch (davi:2788) Bug#45238
Bug#45242 Bug#45243 Bug#46013 Bug#46014 Bug#46030
View as plain text  
# At a local mysql-5.0-bugteam repository of davi

 2788 Davi Arnaut	2009-08-13
      Bug#46013: rpl_extraColmaster_myisam fails on pb2
      Bug#45243: crash on win in sql thread clear_tables_to_lock() -> free()
      Bug#45242: crash on win in mysql_close() -> free()
      Bug#45238: rpl_slave_skip, rpl_change_master failed (lost connection) for STOP SLAVE
      Bug#46030: rpl_truncate_3innodb causes server crash on windows
      Bug#46014: rpl_stm_reset_slave crashes the server sporadically in pb2
      When killing a user session on the server, it's necessary to
      interrupt (notify) the thread associated with the session that
      the connection is being killed so that the thread is woken up
      if waiting for I/O. On a few platforms (Mac, Windows and HP-UX)
      where the SIGNAL_WITH_VIO_CLOSE flag is defined, this interruption
      procedure is to asynchronously close the underlying socket of
      the connection.
      In order to enable this schema, each connection serving thread
      registers its VIO (I/O interface) so that other threads can
      access it and close the connection. But only the owner thread of
      the VIO might delete it as to guarantee that other threads won't
      see freed memory (the thread unregisters the VIO before deleting
      it). A side note: closing the socket introduces a harmless race
      that might cause a thread attempt to read from a closed socket,
      but this is deemed acceptable.
      The problem is that this infrastructure was meant to only be used
      by server threads, but the slave I/O thread was registering the
      VIO of a mysql handle (a client API structure that represents a
      connection to another server instance) as a active connection of
      the thread. But under some circumstances such as network failures,
      the client API might destroy the VIO associated with a handle at
      will, yet the VIO wouldn't be properly unregistered. This could
      lead to accesses to freed data if a thread attempted to kill a
      slave I/O thread whose connection was already broken.
      There was a attempt to work around this by checking whether
      the socket was being interrupted, but this hack didn't work as
      intended due to the aforementioned race -- attempting to read
      from the socket would yield a "bad file descriptor" error.
      The solution is to add a hook to the client API that is called
      from the client code before the VIO of a handle is deleted.
      This hook allows the slave I/O thread to detach the active vio
      so it does not point to freed memory.
     @ server-tools/instance-manager/
        Add stub method required for linking.
     @ sql-common/client.c
        Invoke hook.
     @ sql/client_settings.h
        Export hook.
     @ sql/
        Introduce hook that clears the active VIO before it is freed
        by the client API.

=== modified file 'server-tools/instance-manager/'
--- a/server-tools/instance-manager/	2009-02-10 22:47:54 +0000
+++ b/server-tools/instance-manager/	2009-08-13 20:07:20 +0000
@@ -120,6 +120,18 @@ void my_net_local_init(NET *net)
+  Unused stub hook required for linking the client API.
+void slave_io_thread_detach_vio()
   Every resource, which we can fail to acquire, is allocated in init().

=== modified file 'sql-common/client.c'
--- a/sql-common/client.c	2009-06-10 13:59:59 +0000
+++ b/sql-common/client.c	2009-08-13 20:07:20 +0000
@@ -911,6 +911,9 @@ void end_server(MYSQL *mysql)
     DBUG_PRINT("info",("Net: %s", vio_description(mysql->net.vio)));
+    slave_io_thread_detach_vio();

=== modified file 'sql/client_settings.h'
--- a/sql/client_settings.h	2006-12-31 00:02:27 +0000
+++ b/sql/client_settings.h	2009-08-13 20:07:20 +0000
@@ -33,3 +33,11 @@
 #define mysql_server_init(a,b,c) 0
+void slave_io_thread_detach_vio();
+#define slave_io_thread_detach_vio()

=== modified file 'sql/'
--- a/sql/	2009-07-24 15:58:58 +0000
+++ b/sql/	2009-08-13 20:07:20 +0000
@@ -4737,6 +4737,31 @@ void end_relay_log_info(RELAY_LOG_INFO* 
+  Hook to detach the active VIO before closing a connection handle.
+  The client API might close the connection (and associated data)
+  in case it encounters a unrecoverable (network) error. This hook
+  is called from the client code before the VIO handle is deleted
+  allows the thread to detach the active vio so it does not point
+  to freed memory.
+  Other calls to THD::clear_active_vio throughout this module are
+  redundant due to the hook but are left in place for illustrative
+  purposes.
+extern "C" void slave_io_thread_detach_vio()
+  THD *thd= current_thd;
+  if (thd->slave_thread)
+    thd->clear_active_vio();
   Try to connect until successful or slave killed

Attachment: [text/bzr-bundle] bzr/
bzr commit into mysql-5.0-bugteam branch (davi:2788) Bug#45238Bug#45242 Bug#45243 Bug#46013 Bug#46014 Bug#46030Davi Arnaut13 Aug
  • Re: bzr commit into mysql-5.0-bugteam branch (davi:2788) Bug#45238Bug#45242 Bug#45243 Bug#46013 Bug#46014 Bug#46030Konstantin Osipov13 Aug