Bug #83102 deadlock in mysql_server_init on restarting embedded server in the same process
Submitted: 22 Sep 2016 15:58 Modified: 22 Sep 2016 17:17
Reporter: Daniel Beer Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Embedded Library ( libmysqld ) Severity:S3 (Non-critical)
Version:5.6.33 OS:Red Hat (6.6)
Assigned to: CPU Architecture:Any

[22 Sep 2016 15:58] Daniel Beer
Description:
mysql_client_test_embedded hangs when running test "test_embedded_start_stop". The issue seems to be a deadlock in mysql_server_init, which is stuck waiting on log_sys->checkpoint_lock.

Stack trace:
#0  0x00d43430 in __kernel_vsyscall ()
#1  0x00a9e43c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
#2  0x0877b794 in os_cond_wait(pthread_cond_t*, os_fast_mutex_t*) ()
#3  0x0877bd67 in os_event_wait_low(os_event*, long long) ()
#4  0x0883e0ed in sync_array_wait_event(sync_array_t*, unsigned long) ()
#5  0x08840455 in rw_lock_s_lock_spin(rw_lock_t*, unsigned long, char const*, unsigned long) ()
#6  0x087632b8 in rw_lock_s_lock_func ()
#7  0x08763704 in pfs_rw_lock_s_lock_func ()
#8  0x08765bfa in recv_synchronize_groups() ()
#9  0x08769fde in recv_recovery_from_checkpoint_start_func(unsigned long long, unsigned long long) ()
#10 0x0883c348 in innobase_start_or_create_for_mysql() ()
#11 0x086f92e8 in innobase_init(void*) ()
#12 0x08316275 in ha_initialize_handlerton(st_plugin_int*) ()
#13 0x08474521 in plugin_initialize(st_plugin_int*) ()
#14 0x08474ee7 in plugin_init(int*, char**, int) ()
#15 0x082ccf6c in init_server_components() ()
#16 0x082d1ba7 in init_embedded_server ()
#17 0x0828d991 in mysql_server_init ()
#18 0x082415ba in test_embedded_start_stop ()
#19 0x0821b7bc in main ()

How to repeat:
Build and run mysql_client_test_embedded with mysql 5.6.33:

$ mkdir /tmp/testdb
$ mysql_install_db --datadir=/tmp/testdb
$ mysql_client_test_embedded --server-arg=--datadir=/tmp/testdb test_embedded_start_stop

#####################################
client_connect  
#####################################

 Establishing a connection to '' ...OK
Connected to MySQL server version: 5.6.33-embedded-debug (50633)

 Creating a test database 'client_test_db' ...OK

#####################################
1 of (1/1): test_embedded_start_stop  
#####################################

#####################################
client_disconnect  
#####################################

 closing the connection ...OK

(hangs indefinitely)
[22 Sep 2016 17:15] Miguel Solorzano
Thank you for the bug report.

http://dev.mysql.com/doc/refman/5.6/en/libmysqld-restrictions.html

23.7.2 Restrictions When Using the Embedded MySQL Server

<cut>

InnoDB is not reentrant in the embedded server and cannot be used for multiple connections, either successively or simultaneously.
[22 Sep 2016 17:17] Daniel Beer
Thanks for the update, seems like this test case should be removed from mysql_client_test in that case. I'll put in a separate feature request for this.