Draft: Introduce feature INSTANT_FAILOVER_TARGET
See https://github.com/MariaDB/server/pull/3224 and https://github.com/mariadb-corporation/mariadb-connector-c/pull/245
This is still a draft as unfortunately the feature does not seem to fully work. The configuration works correctly on the server side, e.g.:
../client/mariadb --defaults-file=/tmp/build/source/builddir/mysql-test/var/log/main.instant_failover/my.cnf --host 127.0.0.1 -e 'STATUS; SHOW GLOBAL VARIABLES LIKE "instant_failover_%";'
--------------
../client/mariadb from 11.4.2-MariaDB, client 15.2 for debian-linux-gnu (x86_64) using EditLine wrapper
Connection id: 4
Current database:
Current user: root@localhost
SSL: Cipher in use is TLS_AES_256_GCM_SHA384, cert is UNKNOWN
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server: MariaDB
Server version: 11.4.2-MariaDB-3-log Debian n/a
Protocol version: 10
Connection: 127.0.0.1 via TCP/IP
Server characterset: latin1
Db characterset: latin1
Client characterset: latin1
Conn. characterset: latin1
TCP port: 16000
Uptime: 1 min 6 sec
Threads: 1 Questions: 9 Slow queries: 0 Opens: 17 Open tables: 10 Queries per second avg: 0.136
--------------
+-------------------------+-------+
| Variable_name | Value |
+-------------------------+-------+
| instant_failover_mode | OFF |
| instant_failover_target | |
+-------------------------+-------+
../client/mariadb --defaults-file=/tmp/build/source/builddir/mysql-test/var/log/main.instant_failover/my.cnf --host 127.0.0.1 -e 'set global instant_failover_target="127.0.0.2";set global instant_failover_mode=ON;'
However the client side does not seem to follow the redirect, and just fails to connect no matter what I try:
../client/mariadb --defaults-file=/tmp/build/source/builddir/mysql-test/var/log/main.instant_failover/my.cnf --follow-instant-failovers --reconnect --host 127.0.0.1
ERROR 4196 (HY000): |Server is directing clients to the alternative server '127.0.0.2'|127.0.0.2
This problem is also reflected in the MTR:
main.instant_failover [ fail ]
Test ended at 2024-07-07 00:27:08
CURRENT_TEST: main.instant_failover
ERROR 4196 (HY000): |Server is directing clients to the alternative server '127.0.0.1:16001'|127.0.0.1:16001
mysqltest: At line 31: query 'connect OKAY,127.0.0.1,root,,test,$MASTER_MYPORT' failed: ER_INSTANT_FAILOVER (4196): |Server is directing clients to the alternative server '127.0.0.1:16001'|127.0.0.1:16001
The result from queries just before the failure was:
call mtr.add_suppression("\\[Warning\\] Redirecting connection \\d+ via \\S+ to INSTANT_FAILOVER_TARGET=\\S+ \\(INSTANT_FAILOVER_MODE=\\w+\\)");
Verify that a TCP connection works with --disable-follow-instant-failovers (before enabling instant failover)
default_port_tcp_works
1
Verify that connections via local socket and extra port SUCCEED
connection default;
connect local_sock,localhost,root,,test;
disconnect local_sock;
connect tcp_sock,127.0.0.1,root,,test,$MASTER_EXTRA_PORT;
disconnect tcp_sock;
Enable instant failover in its default mode (ON)
connection default;
set global instant_failover_mode=ON;
set global instant_failover_target="127.0.0.1:$MASTER_EXTRA_PORT"
With --disable-follow-instant-failovers, connecting to the default port should now fail
With --follow-instant-failovers (the client library default), this should redirect to the extra port
Edited by Otto Kekäläinen