From d3c3f3a736ecb0d063708bb804b6a067d190c7dd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= <jan.lindstrom@galeracluster.com>
Date: Thu, 17 Aug 2023 12:16:55 +0300
Subject: [PATCH] MENT-1922 : galera_partition test: assertion due to unallowed
 state transition

Reduce test to minimal to avoid overloading test machines.
Do RSU on its own connection and cleanup session.
---
 mysql-test/suite/galera/disabled.def          |  1 -
 .../suite/galera/r/galera_partition.result    | 25 +++--------
 .../suite/galera/t/galera_partition.cnf       | 22 ----------
 .../suite/galera/t/galera_partition.test      | 43 ++++++-------------
 4 files changed, 21 insertions(+), 70 deletions(-)
 delete mode 100644 mysql-test/suite/galera/t/galera_partition.cnf

diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def
index 03c8b600a34..6326a3492ad 100644
--- a/mysql-test/suite/galera/disabled.def
+++ b/mysql-test/suite/galera/disabled.def
@@ -24,6 +24,5 @@ galera_insert_bulk : MDEV-30536 no expected deadlock in galera_insert_bulk test
 versioning_trx_id : MDEV-18590: galera.versioning_trx_id: Test failure: mysqltest: Result content mismatch
 galera_ssl_mode_server_x509 : hangs on connection
 galera_bf_abort_group_commit : temporary disabled due MDEV-30855
-galera_partition : MENT-1922 assertion due to unallowed state transition
 galera_sequences : temporary disabled as unstable test
 GCF-360 : temporary disabled as unstable test
diff --git a/mysql-test/suite/galera/r/galera_partition.result b/mysql-test/suite/galera/r/galera_partition.result
index 0e8894794d7..7b4d6e41054 100644
--- a/mysql-test/suite/galera/r/galera_partition.result
+++ b/mysql-test/suite/galera/r/galera_partition.result
@@ -3,8 +3,6 @@ connection node_1;
 connection node_1;
 call mtr.add_suppression("WSREP: RSU failed due to pending transactions, schema: test, query ALTER.*");
 call mtr.add_suppression("WSREP: ALTER TABLE isolation failure");
-connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3;
-connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4;
 connection node_1;
 CREATE TABLE t1(
 id bigint unsigned NOT NULL AUTO_INCREMENT,
@@ -396,33 +394,24 @@ insert into t1 (id, dt) values (350, '2010-12-17 00:00:00');
 SELECT COUNT(*) FROM t1;
 COUNT(*)
 350
-connection node_2;
-call mtr.add_suppression("WSREP: Sending JOIN failed:");
-call p1(10);
-connection node_3;
-call mtr.add_suppression("WSREP: Sending JOIN failed:");
-call p1(10);
-connection node_4;
-call mtr.add_suppression("WSREP: Sending JOIN failed:");
-call p1(10);
 connection node_1;
+call p1(10);;
+connection node_2;
+connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2;
+connection node_2a;
 SET SESSION wsrep_OSU_method='RSU';
-SELECT @@wsrep_OSU_method;
-@@wsrep_OSU_method
-RSU
 SET SESSION sql_log_bin = 0;
 ALTER TABLE t1 DROP PARTITION rx2009xx;
 ALTER TABLE t1 DROP PARTITION rx201004;
 ALTER TABLE t1 DROP PARTITION rx201008;
 SET SESSION wsrep_OSU_METHOD='TOI';
+SET SESSION sql_log_bin = 1;
 SELECT @@wsrep_OSU_method;
 @@wsrep_OSU_method
 TOI
 connection node_2;
-connection node_3;
-connection node_4;
+disconnect node_2a;
+connection node_1;
 connection node_1;
 DROP TABLE t1;
 DROP PROCEDURE p1;
-disconnect node_3;
-disconnect node_4;
diff --git a/mysql-test/suite/galera/t/galera_partition.cnf b/mysql-test/suite/galera/t/galera_partition.cnf
deleted file mode 100644
index 525eece04ab..00000000000
--- a/mysql-test/suite/galera/t/galera_partition.cnf
+++ /dev/null
@@ -1,22 +0,0 @@
-!include ../galera_4nodes.cnf
-
-[mysqld.1]
-wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=10M;gmcast.segment=1'
-wsrep_slave_threads=10
-wsrep_debug=1
-
-[mysqld.2]
-wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=10M;gmcast.segment=1'
-wsrep_slave_threads=10
-wsrep_debug=1
-
-[mysqld.3]
-wsrep_provider_options='base_port=@mysqld.3.#galera_port;gcache.size=10M;gmcast.segment=2'
-wsrep_slave_threads=10
-wsrep_debug=1
-
-[mysqld.4]
-wsrep_provider_options='base_port=@mysqld.4.#galera_port;gcache.size=10M;gmcast.segment=3'
-wsrep_slave_threads=10
-wsrep_debug=1
-
diff --git a/mysql-test/suite/galera/t/galera_partition.test b/mysql-test/suite/galera/t/galera_partition.test
index 3de45d54000..269291311f1 100644
--- a/mysql-test/suite/galera/t/galera_partition.test
+++ b/mysql-test/suite/galera/t/galera_partition.test
@@ -1,17 +1,15 @@
 --source include/galera_cluster.inc
 --source include/have_partition.inc
 --source include/big_test.inc
+--source include/force_restart.inc
 
 --connection node_1
 
 call mtr.add_suppression("WSREP: RSU failed due to pending transactions, schema: test, query ALTER.*");
 call mtr.add_suppression("WSREP: ALTER TABLE isolation failure");
 
---connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
---connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4
-
 --connection node_1
---let $wait_condition = SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
 --source include/wait_condition.inc
 
 CREATE TABLE t1(
@@ -408,50 +406,37 @@ insert into t1 (id, dt) values (350, '2010-12-17 00:00:00');
 
 SELECT COUNT(*) FROM t1;
 
---connection node_2
-call mtr.add_suppression("WSREP: Sending JOIN failed:");
-send call p1(10);
-
---connection node_3
-call mtr.add_suppression("WSREP: Sending JOIN failed:");
-send call p1(10);
+--connection node_1
+--send call p1(10);
 
---connection node_4
-call mtr.add_suppression("WSREP: Sending JOIN failed:");
-send call p1(10);
+--connection node_2
 
---connection node_1
+--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
+--connection node_2a
 SET SESSION wsrep_OSU_method='RSU';
-SELECT @@wsrep_OSU_method;
 SET SESSION sql_log_bin = 0;
 
---error 0,ER_LOCK_DEADLOCK
+--error 0,ER_LOCK_DEADLOCK,ER_LOCK_WAIT_TIMEOUT
 ALTER TABLE t1 DROP PARTITION rx2009xx;
---error 0,ER_LOCK_DEADLOCK
+--error 0,ER_LOCK_DEADLOCK,ER_LOCK_WAIT_TIMEOUT
 ALTER TABLE t1 DROP PARTITION rx201004;
---error 0,ER_LOCK_DEADLOCK
+--error 0,ER_LOCK_DEADLOCK,ER_LOCK_WAIT_TIMEOUT
 ALTER TABLE t1 DROP PARTITION rx201008;
 
 SET SESSION wsrep_OSU_METHOD='TOI';
+SET SESSION sql_log_bin = 1;
 SELECT @@wsrep_OSU_method;
 
 --connection node_2
---error 0,ER_LOCK_DEADLOCK
-reap;
+--disconnect node_2a
 
---connection node_3
---error 0,ER_LOCK_DEADLOCK
-reap;
-
---connection node_4
---error 0,ER_LOCK_DEADLOCK
+--connection node_1
+--error 0,ER_LOCK_DEADLOCK,ER_LOCK_WAIT_TIMEOUT
 reap;
 
 --connection node_1
 DROP TABLE t1;
 DROP PROCEDURE p1;
 
---disconnect node_3
---disconnect node_4
 
 
-- 
2.39.2

