Skip to content

Commit

Permalink
MDEV-33523 Spurious deadlock error when wsrep_on=OFF
Browse files Browse the repository at this point in the history
Avoid starting transactions in wsrep-lib side when wsrep is
disabled. It is unnecessary, and causes spurious deadlock errors on
transaction clean up.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
  • Loading branch information
sciascid authored and sysprg committed Jun 6, 2024
1 parent d328705 commit c1dc039
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 12 deletions.
3 changes: 3 additions & 0 deletions mysql-test/suite/galera/galera_2nodes_as_master.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port'
wsrep-on=OFF
server-id=3

[sst]
sst-log-archive-dir=@ENV.MYSQLTEST_VARDIR/log

[ENV]
NODE_MYPORT_1= @mysqld.1.port
NODE_MYSOCK_1= @mysqld.1.socket
Expand Down
3 changes: 3 additions & 0 deletions mysql-test/suite/galera/galera_2nodes_as_slave.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port'
wsrep-on=OFF
server-id=3

[sst]
sst-log-archive-dir=@ENV.MYSQLTEST_VARDIR/log

[ENV]
NODE_MYPORT_1= @mysqld.1.port
NODE_MYSOCK_1= @mysqld.1.socket
Expand Down
6 changes: 3 additions & 3 deletions mysql-test/suite/galera/galera_2x2nodes.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ default-storage-engine=innodb
wsrep_gtid_mode=1
gtid_ignore_duplicates
auto_increment_increment=3

wsrep-provider=@ENV.WSREP_PROVIDER
# enforce read-committed characteristics across the cluster
# wsrep-causal-reads=ON
Expand Down Expand Up @@ -61,6 +60,9 @@ wsrep_node_address='127.0.0.1:@mysqld.4.#galera_port'
wsrep_node_incoming_address=127.0.0.1:@mysqld.4.port
wsrep_sst_receive_address='127.0.0.1:@mysqld.4.#sst_port'

[sst]
sst-log-archive-dir=@ENV.MYSQLTEST_VARDIR/log

[ENV]
NODE_MYPORT_1= @mysqld.1.port
NODE_MYSOCK_1= @mysqld.1.socket
Expand All @@ -73,5 +75,3 @@ NODE_MYSOCK_3= @mysqld.3.socket

NODE_MYPORT_4= @mysqld.4.port
NODE_MYSOCK_4= @mysqld.4.socket


3 changes: 3 additions & 0 deletions mysql-test/suite/galera/galera_3nodes_as_slave.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.3.#sst_port'
wsrep-on=OFF
server-id=4

[sst]
sst-log-archive-dir=@ENV.MYSQLTEST_VARDIR/log

[ENV]
NODE_MYPORT_1= @mysqld.1.port
NODE_MYSOCK_1= @mysqld.1.socket
Expand Down
3 changes: 3 additions & 0 deletions mysql-test/suite/galera/galera_4nodes.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ wsrep_node_incoming_address=127.0.0.1:@mysqld.4.port
wsrep_sst_receive_address='127.0.0.1:@mysqld.4.#sst_port'
auto-increment-offset=4

[sst]
sst-log-archive-dir=@ENV.MYSQLTEST_VARDIR/log

[ENV]
NODE_MYPORT_1= @mysqld.1.port
NODE_MYSOCK_1= @mysqld.1.socket
Expand Down
6 changes: 6 additions & 0 deletions mysql-test/suite/galera/r/MDEV-33523.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
connection node_2;
connection node_1;
SET SESSION wsrep_on=OFF;
BEGIN;
ROLLBACK;
SET SESSION wsrep_on=OFF;
11 changes: 9 additions & 2 deletions mysql-test/suite/galera/r/galera_bf_kill.result
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,23 @@ a b
disconnect node_2a;
disconnect node_2b;
connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2;
connect node_2b, 127.0.0.1, root, , test, $NODE_MYPORT_2;
connection node_2a;
SET SESSION wsrep_on=OFF;
begin;
update t1 set a =5, b=2;
connection node_2;
ALTER TABLE t1 ADD UNIQUE KEY b3(b);
connection node_2b;
SET SESSION wsrep_sync_wait=0;
connection node_2a;
select * from t1;
a b
2 1
5 2
commit;
connection node_2;
disconnect node_2a;
disconnect node_2b;
connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2;
connection node_2a;
SET SESSION wsrep_on=OFF;
Expand All @@ -67,7 +74,7 @@ update t1 set a =5, b=2;
connection node_2;
select * from t1;
a b
2 1
5 2
disconnect node_2a;
connection node_1;
drop table t1;
11 changes: 11 additions & 0 deletions mysql-test/suite/galera/t/MDEV-33523.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# MDEV-33523: Spurious deadlock error when wsrep_on=OFF
#
--source include/galera_cluster.inc

SET SESSION wsrep_on=OFF;
BEGIN;
# If bug is present, the following rollback
# results in ER_LOCK_DEADLOCK error.
ROLLBACK;
SET SESSION wsrep_on=OFF;
28 changes: 22 additions & 6 deletions mysql-test/suite/galera/t/galera_bf_kill.test
Original file line number Diff line number Diff line change
Expand Up @@ -94,27 +94,43 @@ select * from t1;
--disconnect node_2b

#
# Test case 5: Start a transaction on node_2a with wsrep disabled
# and start a DDL on other transaction that will then abort node_2a
# transactions
# Test case 5: Start a transaction on node_2a with wsrep disabled.
# A conflicting DDL on other transaction can't BF abort
# transaction from node_2a (wsrep disabled).
#

--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
--connect node_2b, 127.0.0.1, root, , test, $NODE_MYPORT_2
--connection node_2a
SET SESSION wsrep_on=OFF;
begin;
update t1 set a =5, b=2;

--connection node_2
ALTER TABLE t1 ADD UNIQUE KEY b3(b);
--send ALTER TABLE t1 ADD UNIQUE KEY b3(b)

--connection node_2b
SET SESSION wsrep_sync_wait=0;
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'Waiting for table metadata lock';
--source include/wait_condition.inc

--connection node_2a
select * from t1;

# We expect that ALTER should not be able to BF abort
# this transaction, it must wait for it to finish.
# Expect commit to succeed.
commit;

--connection node_2
--reap

--disconnect node_2a
--disconnect node_2b

#
# Test case 6: Start a transaction on node_2a with wsrep disabled
# and kill it from other connection on same node
# Test case 6: Start a transaction on node_2a with wsrep disabled
# and kill it from other connection on same node.
#

--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
Expand Down
3 changes: 3 additions & 0 deletions mysql-test/suite/galera_3nodes/galera_2x3nodes.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ wsrep_node_address='127.0.0.1:@mysqld.6.#galera_port'
wsrep_node_incoming_address=127.0.0.1:@mysqld.6.port
wsrep_sst_receive_address='127.0.0.1:@mysqld.6.#sst_port'

[sst]
sst-log-archive-dir=@ENV.MYSQLTEST_VARDIR/log

[ENV]
NODE_MYPORT_1= @mysqld.1.port
NODE_MYSOCK_1= @mysqld.1.socket
Expand Down
3 changes: 3 additions & 0 deletions mysql-test/suite/galera_3nodes/galera_3nodes.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ wsrep_node_address='127.0.0.1:@mysqld.3.#galera_port'
wsrep_node_incoming_address=127.0.0.1:@mysqld.3.port
wsrep_sst_receive_address='127.0.0.1:@mysqld.3.#sst_port'

[sst]
sst-log-archive-dir=@ENV.MYSQLTEST_VARDIR/log

[ENV]
NODE_MYPORT_1= @mysqld.1.port
NODE_MYSOCK_1= @mysqld.1.socket
Expand Down
2 changes: 1 addition & 1 deletion sql/transaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ bool trans_begin(THD *thd, uint flags)
}

#ifdef WITH_WSREP
if (wsrep_thd_is_local(thd))
if (WSREP(thd) && wsrep_thd_is_local(thd))
{
if (wsrep_sync_wait(thd))
DBUG_RETURN(TRUE);
Expand Down

0 comments on commit c1dc039

Please sign in to comment.