Skip to content

Commit 889367b

Browse files
committed
fix(tests): clear MariaDB GTID slave state when repointing replicas
MariaDB relay-drain ensure_flat failed with errno 1950 (gtid strict out-of-order) after prior local GTIDs on replicas. Disable strict mode in test cnf, RESET + clear gtid_slave_pos on repoint, and require both IO and SQL running in setup-replication.
1 parent d8b33de commit 889367b

5 files changed

Lines changed: 17 additions & 19 deletions

File tree

‎tests/functional/mysql/mariadb-master.cnf‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ server-id=1
33
log-bin=mysql-bin
44
binlog-format=ROW
55
log-slave-updates=ON
6-
gtid_strict_mode=ON
6+
gtid_strict_mode=OFF
77
binlog-row-image=MINIMAL
88
report-host=mysql1

‎tests/functional/mysql/mariadb-replica.cnf‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ server-id=2
33
log-bin=mysql-bin
44
binlog-format=ROW
55
log-slave-updates=ON
6-
gtid_strict_mode=ON
6+
gtid_strict_mode=OFF
77
binlog-row-image=MINIMAL
88
read_only=ON
99
report-host=mysql2

‎tests/functional/mysql/mariadb-replica2.cnf‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ server-id=3
33
log-bin=mysql-bin
44
binlog-format=ROW
55
log-slave-updates=ON
6-
gtid_strict_mode=ON
6+
gtid_strict_mode=OFF
77
binlog-row-image=MINIMAL
88
read_only=ON
99
report-host=mysql3

‎tests/functional/setup-replication.sh‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ echo "Verifying replication..."
4040
for REPLICA in mysql2 mysql3; do
4141
for i in $(seq 1 60); do
4242
if echo "$MYSQL_FULL_VERSION" | grep -qi mariadb; then
43-
STATUS=$($COMPOSE exec -T "$REPLICA" mysql -uroot -ptestpass -e \
44-
"SHOW SLAVE STATUS\G" 2>/dev/null | awk '/Slave_IO_Running:/{print $2; exit}' | tr -d '[:space:]')
45-
if [ "$STATUS" = "Yes" ]; then
46-
echo "$REPLICA: replication OK (IO thread Yes)"
43+
IO=$($COMPOSE exec -T "$REPLICA" mysql -uroot -ptestpass -e \
44+
"SHOW SLAVE STATUS\G" 2>/dev/null | awk -F': *' '/Slave_IO_Running:/{print $2; exit}' | tr -d '[:space:]')
45+
SQL=$($COMPOSE exec -T "$REPLICA" mysql -uroot -ptestpass -e \
46+
"SHOW SLAVE STATUS\G" 2>/dev/null | awk -F': *' '/Slave_SQL_Running:/{print $2; exit}' | tr -d '[:space:]')
47+
if [ "$IO" = "Yes" ] && [ "$SQL" = "Yes" ]; then
48+
echo "$REPLICA: replication OK (IO+SQL Yes)"
4749
break
4850
fi
4951
else

‎tests/functional/test-mariadb-relay-drain.sh‎

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,17 @@ nudge_replica_threads() {
7979
repoint_replica_to_mysql1() {
8080
local r="$1"
8181
$COMPOSE exec -T "$r" mysql -uroot -ptestpass -e "STOP REPLICA; STOP SLAVE;" 2>/dev/null || true
82-
# Skip RESET when possible — RESET wipes GTID state and often leaves SQL=No on MariaDB
83-
# until positions are re-established. Prefer CHANGE + START first.
84-
if ! $COMPOSE exec -T "$r" mysql -uroot -ptestpass -e "
82+
# RESET drops errant/local GTID history from prior failover tests.
83+
# MariaDB errno 1950: out-of-order GTID when gtid_slave_pos / strict mode conflict.
84+
$COMPOSE exec -T "$r" mysql -uroot -ptestpass -e "$RESET_REPLICA" 2>/dev/null || true
85+
if mysql_is_mariadb; then
86+
$COMPOSE exec -T "$r" mysql -uroot -ptestpass -e "SET GLOBAL gtid_slave_pos=''; SET GLOBAL gtid_strict_mode=OFF;" 2>/dev/null || true
87+
fi
88+
$COMPOSE exec -T "$r" mysql -uroot -ptestpass -e "
8589
$CHANGE_TO_MYSQL1
8690
SET GLOBAL read_only=1;
8791
$START_REPLICA
88-
" 2>/dev/null; then
89-
$COMPOSE exec -T "$r" mysql -uroot -ptestpass -e "
90-
$STOP_REPLICA
91-
$RESET_REPLICA
92-
$CHANGE_TO_MYSQL1
93-
SET GLOBAL read_only=1;
94-
$START_REPLICA
95-
" 2>/dev/null || true
96-
fi
92+
" 2>/dev/null || true
9793
nudge_replica_threads "$r"
9894
}
9995

0 commit comments

Comments
 (0)