Bug #40935 Crash upon server restart after installation of plugins
Submitted: 21 Nov 2008 18:06 Modified: 14 Apr 2009 22:44
Reporter: Paul DuBois Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:6.0 bzr OS:Any
Assigned to: Assigned Account CPU Architecture:Any
Tags: Contribution

[21 Nov 2008 18:06] Paul DuBois
Description:
I tried the preview release of the semisynchronous replication plugins. After installing either one, the server crashes when you restart it.

How to repeat:
* Install either plugin with INSTALL plugin.
* Restart the server. It will fail to start up. It is necessary to restart the server with --skip-grant-tables (which suppresses plugin loading) and remove the plugin line from the mysql.plugin table before the server will start up properly.

The information in the error log looks like this:

081121 10:38:09 - mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

key_buffer_size=8388572
read_buffer_size=131072
max_used_connections=0
max_threads=151
thread_count=0
connection_count=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 337803 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd: 0xbff1c800
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0xbff1e394 thread_stack 0x30c00
/var/mysql/60009/libexec/mysqld(my_print_stacktrace+0x22) [0x875055c]
/var/mysql/60009/libexec/mysqld(handle_segfault+0x2cd) [0x82d6bb2]
[0xffffe400]
/var/mysql/60009/libexec/mysqld(mdl_release_locks(MDL_CONTEXT*)+0xe6) [0x84ce4bb]
/var/mysql/60009/libexec/mysqld(close_thread_tables(THD*, bool)+0x2ed) [0x8333c59]
/var/mysql/60009/libexec/mysqld [0x84ba30c]
/var/mysql/60009/libexec/mysqld(plugin_init(int*, char**, int)+0x58c) [0x84bac4f]
/var/mysql/60009/libexec/mysqld [0x82da409]
/var/mysql/60009/libexec/mysqld(main+0x215) [0x82daec2]
/lib/libc.so.6(__libc_start_main+0xe5) [0xb7c26635]
/var/mysql/60009/libexec/mysqld [0x81f4ef1]
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at (nil) is an invalid pointer
thd->thread_id=0
thd->killed=NOT_KILLED
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
[24 Nov 2008 3:48] Zhenxing He
This is not specific to semi-synchronous, you'll get a crash with any
plugins, I think the problem is in plugin_load, where the 'tmp_root' is
freed before calling close_thread_tables, so the memory allocated for
the MDL locks are freed and caused the crash.

I think the following patch can fix this.

=== modified file 'sql/sql_plugin.cc'
*** sql/sql_plugin.cc   2008-11-06 18:39:27 +0000
--- sql/sql_plugin.cc   2008-11-23 05:54:59 +0000
***************
*** 1384,1390 ****
      if (plugin_add(tmp_root, &name, &dl, argc, argv, REPORT_TO_LOG))
        sql_print_warning("Couldn't load plugin named '%s' with soname '%s'.",
                          str_name.c_ptr(), str_dl.c_ptr());
-     free_root(tmp_root, MYF(MY_MARK_BLOCKS_FREE));
    }
    pthread_mutex_unlock(&LOCK_plugin);
    if (error > 0)
--- 1384,1389 ----
***************
*** 1393,1398 ****
--- 1392,1398 ----
    new_thd->version--; // Force close to free memory
  end:
    close_thread_tables(new_thd);
+   free_root(tmp_root, MYF(MY_MARK_BLOCKS_FREE));
    /* Remember that we don't have a THD */
    my_pthread_setspecific_ptr(THR_THD, 0);
    DBUG_VOID_RETURN;
[4 Apr 2009 20:04] Sveta Smirnova
Thank you for the report.

Verified mostly as described.

Backtrace in my env:

stack_bottom = 0xbfd290cc thread_stack 0x20000
./libexec/mysqld(my_print_stacktrace+0x32) [0x88294ae]
./libexec/mysqld(handle_segfault+0x2de) [0x82bfcd8]
[0x2ce420]
./libexec/mysqld(MDL_context::remove_all_requests()+0x43) [0x84dab4d]
./libexec/mysqld(close_thread_tables(THD*, bool)+0x37e) [0x8321460]
./libexec/mysqld [0x84c8002]
./libexec/mysqld(plugin_init(int*, char**, int)+0x64f) [0x84c8691]
./libexec/mysqld [0x82c3f5e]
./libexec/mysqld(main+0x1f3) [0x82c824b]
/lib/libc.so.6(__libc_start_main+0xdf) [0x301d7f]

I installed  rpl_semi_sync_master
[14 Apr 2009 22:44] Davi Arnaut
This is a duplicate of Bug#44137
[14 Apr 2009 22:53] Davi Arnaut
This bug was reported earlier then Bug#44137 and even before transactional DDL locking was pushed to the main tree. But since the latter is already pushed, this one has been closed as a duplicate.