The test case below causes a server-wide deadlock with the following interesting threads:
Thread 2 (Thread 0x7f027439d700 (LWP 23279)):
#0 0x0000003e90c0cf79 in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1 0x00000000006f039d in inline_mysql_cond_timedwait (that=0x3397848, mutex=0x3397818, abstime=0x7f027439a930) at /home/philips/git/codership-mysql/include/mysql/psi/mysql_thread.h:1199
#2 0x00000000006f0fc4 in MDL_wait::timed_wait (this=0x3397818, owner=0x3397730, abs_timeout=0x7f027439a930, set_status_on_timeout=true, wait_state_name=0x1401100 <MDL_key::m_namespace_to_wait_state_name>) at /home/philips/git/codership-mysql/sql/mdl.cc:1338
#3 0x00000000006f2ae5 in MDL_context::acquire_lock (this=0x3397818, mdl_request=0x7f027439aa10, lock_wait_timeout=31536000) at /home/philips/git/codership-mysql/sql/mdl.cc:2365
#4 0x00000000007413fc in open_table (thd=0x3397730, table_list=0x7f0238004d38, ot_ctx=0x7f027439ade0) at /home/philips/git/codership-mysql/sql/sql_base.cc:2865
#5 0x0000000000744272 in open_and_process_table (thd=0x3397730, lex=0x33994e8, tables=0x7f0238004d38, counter=0x3399598, flags=0, prelocking_strategy=0x7f027439aee0, has_prelocking_list=false, ot_ctx=0x7f027439ade0) at /home/philips/git/codership-mysql/sql/sql_base.cc:4631
#6 0x0000000000744f20 in open_tables (thd=0x3397730, start=0x7f027439aea0, counter=0x3399598, flags=0, prelocking_strategy=0x7f027439aee0) at /home/philips/git/codership-mysql/sql/sql_base.cc:5071
#7 0x00000000007460be in open_normal_and_derived_tables (thd=0x3397730, tables=0x7f0238004d38, flags=0) at /home/philips/git/codership-mysql/sql/sql_base.cc:5775
#8 0x0000000000788662 in mysql_insert (thd=0x3397730, table_list=0x7f0238004d38, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false) at /home/philips/git/codership-mysql/sql/sql_insert.cc:737
#9 0x00000000007a8b70 in mysql_execute_command (thd=0x3397730) at /home/philips/git/codership-mysql/sql/sql_parse.cc:3774
#10 0x00000000007b1b04 in mysql_parse (thd=0x3397730, rawbuf=0x7f0238004c50 "INSERT INTO t1 VALUES (2)", length=25, parser_state=0x7f027439c730) at /home/philips/git/codership-mysql/sql/sql_parse.cc:6815
#11 0x00000000007b114c in wsrep_mysql_parse (thd=0x3397730, rawbuf=0x7f0238004c50 "INSERT INTO t1 VALUES (2)", length=25, parser_state=0x7f027439c730) at /home/philips/git/codership-mysql/sql/sql_parse.cc:6595
#12 0x00000000007a3604 in dispatch_command (command=COM_QUERY, thd=0x3397730, packet=0x33c5511 "INSERT INTO t1 VALUES (2)", packet_length=25) at /home/philips/git/codership-mysql/sql/sql_parse.cc:1525
#13 0x00000000007a21ec in do_command (thd=0x3397730) at /home/philips/git/codership-mysql/sql/sql_parse.cc:1114
#14 0x000000000076f48f in do_handle_one_connection (thd_arg=0x3397730) at /home/philips/git/codership-mysql/sql/sql_connect.cc:1007
#15 0x000000000076efc5 in handle_one_connection (arg=0x3397730) at /home/philips/git/codership-mysql/sql/sql_connect.cc:916
#16 0x0000003e90c0753a in start_thread () from /lib64/libpthread.so.0
#17 0x0000003e905045fd in clone () from /lib64/libc.so.6
and
Thread 21 (Thread 0x7f0277fff700 (LWP 23093)):
#0 0x0000003e90c0cbd0 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1 0x00007f028f382586 in wait (this=0x7f0277ffd4b0, cond=...) at galerautils/src/gu_lock.hpp:56
#2 galera::Monitor<galera::ReplicatorSMM::LocalOrder>::enter (this=this@entry=0x31825b0, obj=...) at galera/src/monitor.hpp:120
#3 0x00007f028f37b943 in cert (trx=0x7f026c036620, this=0x3181aa0) at galera/src/replicator_smm.cpp:1663
#4 galera::ReplicatorSMM::cert_and_catch (this=this@entry=0x3181aa0, trx=trx@entry=0x7f026c036620) at galera/src/replicator_smm.cpp:1761
#5 0x00007f028f37ca82 in galera::ReplicatorSMM::process_trx (this=0x3181aa0, recv_ctx=0x7f026c0009a0, trx=0x7f026c036620) at galera/src/replicator_smm.cpp:1207
#6 0x00007f028f357619 in galera::GcsActionSource::dispatch (this=this@entry=0x31820f8, recv_ctx=recv_ctx@entry=0x7f026c0009a0, act=..., exit_loop=@0x7f0277ffe2fc: false) at galera/src/gcs_action_source.cpp:119
#7 0x00007f028f358b42 in galera::GcsActionSource::process (this=0x31820f8, recv_ctx=0x7f026c0009a0, exit_loop=@0x7f0277ffe2fc: false) at galera/src/gcs_action_source.cpp:176
#8 0x00007f028f37d0ab in galera::ReplicatorSMM::async_recv (this=0x3181aa0, recv_ctx=0x7f026c0009a0) at galera/src/replicator_smm.cpp:357
#9 0x00007f028f391018 in galera_recv (gh=<optimized out>, recv_ctx=<optimized out>) at galera/src/wsrep_provider.cpp:231
#10 0x0000000000616392 in wsrep_replication_process (thd=0x7f026c0009a0) at /home/philips/git/codership-mysql/sql/wsrep_thd.cc:309
#11 0x00000000005f83cc in start_wsrep_THD (arg=0x6162e4 <wsrep_replication_process(THD*)>) at /home/philips/git/codership-mysql/sql/mysqld.cc:5374
#12 0x0000003e90c0753a in start_thread () from /lib64/libpthread.so.0
#13 0x0000003e905045fd in clone () from /lib64/libc.so.6
The table in question is permanently locked and can not be accessed.
Test case:
--source include/galera_cluster.inc
--source include/have_innodb.inc
--connection node_1
--let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options`
SET GLOBAL wsrep_provider_options = 'repl.causal_read_timeout=PT2S';
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
FLUSH TABLES WITH READ LOCK;
--connection node_2
INSERT INTO t1 VALUES (1);
--let $galera_connection_name = node_1a
--let $galera_server_number = 1
--source include/galera_connect.inc
--connection node_1a
SET SESSION wsrep_sync_wait = 1;
--error ER_LOCK_WAIT_TIMEOUT
SELECT * FROM t1;
UNLOCK TABLES;
--disable_query_log
--eval SET GLOBAL wsrep_provider_options = '$wsrep_provider_options_orig';
INSERT INTO t1 VALUES (2);