From 526a3c510343562c7d086a75189d4f31134da405 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= <jan.lindstrom@galeracluster.com>
Date: Mon, 28 Aug 2023 11:47:19 +0300
Subject: [PATCH] Stabilize test galera_sequences

---
 .../suite/galera/r/galera_sequences.result    | 20 ++--------
 .../suite/galera/t/galera_sequences.test      | 38 +++++++------------
 2 files changed, 16 insertions(+), 42 deletions(-)

diff --git a/mysql-test/suite/galera/r/galera_sequences.result b/mysql-test/suite/galera/r/galera_sequences.result
index e696a707cdf..5e34a86f5e5 100644
--- a/mysql-test/suite/galera/r/galera_sequences.result
+++ b/mysql-test/suite/galera/r/galera_sequences.result
@@ -155,6 +155,9 @@ a	b
 12	6
 DROP TABLE t1;
 DROP SEQUENCE t;
+connection node_2;
+# Wait DDL to replicate
+connection node_1;
 CREATE SEQUENCE t ENGINE=MYISAM;
 ERROR 42000: This version of MariaDB doesn't yet support 'Galera cluster does support only InnoDB sequences'
 CREATE SEQUENCE t INCREMENT BY 1 NOCACHE ENGINE=INNODB;
@@ -162,23 +165,6 @@ CREATE TABLE t1(a int not null primary key default nextval(t), b int) engine=inn
 connection node_2;
 # Wait DDL to replicate
 connection node_1;
-SELECT @@auto_increment_increment;
-@@auto_increment_increment
-2
-SELECT @@auto_increment_offset;
-@@auto_increment_offset
-1
-SET SESSION wsrep_sync_wait=0;
-connection node_2;
-SELECT @@auto_increment_increment;
-@@auto_increment_increment
-2
-SELECT @@auto_increment_offset;
-@@auto_increment_offset
-2
-SET SESSION wsrep_sync_wait=0;
-connection node_1;
-connection node_2;
 connection node_1;
 DROP SEQUENCE t;
 DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/galera_sequences.test b/mysql-test/suite/galera/t/galera_sequences.test
index 5c03ab973e0..67a4f4759b2 100644
--- a/mysql-test/suite/galera/t/galera_sequences.test
+++ b/mysql-test/suite/galera/t/galera_sequences.test
@@ -126,12 +126,21 @@ SELECT * FROM t1;
 DROP TABLE t1;
 DROP SEQUENCE t;
 
+--connection node_2
+--echo # Wait DDL to replicate
+--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't'
+--source include/wait_condition.inc
+--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'
+--source include/wait_condition.inc
+
+
 #
 # Test Galera SEQUENCE support
 #
 #
 # No MyISAM SEQUENCES
 #
+--connection node_1
 --error ER_NOT_SUPPORTED_YET
 CREATE SEQUENCE t ENGINE=MYISAM;
 CREATE SEQUENCE t INCREMENT BY 1 NOCACHE ENGINE=INNODB;
@@ -148,46 +157,25 @@ CREATE TABLE t1(a int not null primary key default nextval(t), b int) engine=inn
 # Below we do not care order of INSERTs we care only that values are unique
 #
 --connection node_1
-SELECT @@auto_increment_increment;
-SELECT @@auto_increment_offset;
---let $wsrep_sync_wait_orig_1 = `SELECT @@wsrep_sync_wait`
-SET SESSION wsrep_sync_wait=0;
-
---connection node_2
-SELECT @@auto_increment_increment;
-SELECT @@auto_increment_offset;
---let $wsrep_sync_wait_orig_2 = `SELECT @@wsrep_sync_wait`
-SET SESSION wsrep_sync_wait=0;
-
 --let $count = 20
 --disable_query_log
 while ($count)
 {
 --connection node_1
---error 0,ER_LOCK_WAIT_TIMEOUT
+--error 0,ER_LOCK_WAIT_TIMEOUT,ER_LOCK_DEADLOCK
 INSERT INTO t1(b) values (1);
 --connection node_2
---error 0,ER_LOCK_WAIT_TIMEOUT
+--error 0,ER_LOCK_WAIT_TIMEOUT,ER_LOCK_DEADLOCK
 INSERT INTO t1(b) values (2);
---error 0,ER_LOCK_WAIT_TIMEOUT
+--error 0,ER_LOCK_WAIT_TIMEOUT,ER_LOCK_DEADLOCK
 INSERT INTO t1(b) values (2);
 --connection node_1
---error 0,ER_LOCK_WAIT_TIMEOUT
+--error 0,ER_LOCK_WAIT_TIMEOUT,ER_LOCK_DEADLOCK
 INSERT INTO t1(b) values (1);
 --dec $count
 }
 --enable_query_log
 
---connection node_1
---disable_query_log
---eval SET SESSION wsrep_sync_wait = $wsrep_sync_wait_orig_1
---enable_query_log
-
---connection node_2
---disable_query_log
---eval SET SESSION wsrep_sync_wait = $wsrep_sync_wait_orig_2
---enable_query_log
-
 --connection node_1
 DROP SEQUENCE t;
 DROP TABLE t1;
-- 
2.39.2

