From 2fc6bedb120f5becff06711761dee4c64838c1dd Mon Sep 17 00:00:00 2001 From: Rene Cannao Date: Sat, 4 Apr 2026 11:43:27 +0000 Subject: [PATCH] fix: replace \G with --vertical in all replication templates (MySQL 9.5 compat) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MySQL 9.5 client rejects \G in -e mode with "Unknown command '\G'". Replace all instances across templates with --vertical flag which produces the same vertical output format. Templates fixed: - test_replication.gotxt — \G on show master/slave status - check_slaves.gotxt — \G on show master/slave status - check_multi_source.gotxt — \G on show master/slave status - replicate_from.gotxt — \G on show master/replica status Also: - Made master binlog/position grep more robust (handles File/Log_name) - Added guard for empty binlog name in source_pos_wait call - Updated export test for admin ui subcommand count --- .github/workflows/integration_tests.yml | 1 + cmd/export_test.go | 2 +- .../replication/check_multi_source.gotxt | 4 ++-- sandbox/templates/replication/check_slaves.gotxt | 4 ++-- .../templates/replication/test_replication.gotxt | 16 +++++++++++----- sandbox/templates/single/replicate_from.gotxt | 4 ++-- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 8eda6a6..d2827ec 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -21,6 +21,7 @@ jobs: - '8.0.42' - '8.4.4' - '9.1.0' + - '9.5.0' env: GO111MODULE: on SANDBOX_BINARY: ${{ github.workspace }}/opt/mysql diff --git a/cmd/export_test.go b/cmd/export_test.go index 449fff7..3ee3fce 100644 --- a/cmd/export_test.go +++ b/cmd/export_test.go @@ -93,7 +93,7 @@ func TestExportImport(t *testing.T) { subCommandName: "", expectedName: "admin", expectedAncestors: 2, - expectedSubCommands: 6, + expectedSubCommands: 7, expectedArgument: "", }, { diff --git a/sandbox/templates/replication/check_multi_source.gotxt b/sandbox/templates/replication/check_multi_source.gotxt index d69880d..510b823 100644 --- a/sandbox/templates/replication/check_multi_source.gotxt +++ b/sandbox/templates/replication/check_multi_source.gotxt @@ -12,7 +12,7 @@ do port=$($SBDIR/{{.NodeLabel}}$M/use -BN -e "show variables like 'port'") server_id=$($SBDIR/{{.NodeLabel}}$M/use -BN -e "show variables like 'server_id'") echo "$port - $server_id" - $SBDIR/{{.NodeLabel}}$M/use -e '{{.ShowMasterStatus}}\G' | grep "File\|Position\|Executed" + $SBDIR/{{.NodeLabel}}$M/use --vertical -e '{{.ShowMasterStatus}}' | grep "File\|Position\|Executed" done for S in $SLAVES do @@ -20,5 +20,5 @@ do port=$($SBDIR/{{.NodeLabel}}$S/use -BN -e "show variables like 'port'") server_id=$($SBDIR/{{.NodeLabel}}$S/use -BN -e "show variables like 'server_id'") echo "$port - $server_id" - $SBDIR/{{.NodeLabel}}$S/use -e '{{.ShowSlaveStatus}}\G' | grep -E "(Running:|Master_Log_Pos|Source_Log_Pos|\ $master_status -master_binlog=$(grep 'File:' $master_status | awk '{print $2}' ) -master_pos=$(grep 'Position:' $master_status | awk '{print $2}' ) +$MASTER --vertical -e '{{.ShowMasterStatus}}' > $master_status +master_binlog=$(grep -E '^\s*(File|Log_name):' $master_status | awk '{print $2}' ) +master_pos=$(grep -E '^\s*Position:' $master_status | awk '{print $2}' ) echo "# {{.MasterLabel}} log: $master_binlog - Position: $master_pos - Rows: $MASTER_RECS" rm -f $master_status @@ -98,7 +98,13 @@ do then sleep 3 else - S_READY=$($SLAVE -BN -e "select {{.MasterPosWaitFunc}}('$master_binlog', $master_pos,60)") + if [ -z "$master_binlog" ] || [ -z "$master_pos" ]; then + echo "# WARNING: could not determine master binlog/position, using GTID wait" + sleep 3 + S_READY=0 + else + S_READY=$($SLAVE -BN -e "select {{.MasterPosWaitFunc}}('$master_binlog', $master_pos, 60)") + fi # master_pos_wait can return 0 or a positive number for successful replication # Any result that is not NULL or -1 is acceptable if [ "$S_READY" != "-1" -a "$S_READY" != "NULL" ] @@ -109,7 +115,7 @@ do fi if [ -f initialize_{{.SlaveLabel}}s ] then - $SLAVE -e '{{.ShowSlaveStatus}}\G' > $slave_status + $SLAVE --vertical -e '{{.ShowSlaveStatus}}' > $slave_status IO_RUNNING=$(grep -E -w "Slave_IO_Running|Replica_IO_Running" $slave_status | awk '{print $2}') ok_equal $IO_RUNNING Yes "{{.SlaveLabel}} #$SLAVE_N IO thread is running" SQL_RUNNING=$(grep -E -w "Slave_SQL_Running|Replica_SQL_Running" $slave_status | awk '{print $2}') diff --git a/sandbox/templates/single/replicate_from.gotxt b/sandbox/templates/single/replicate_from.gotxt index 5409bfd..1d86ce8 100644 --- a/sandbox/templates/single/replicate_from.gotxt +++ b/sandbox/templates/single/replicate_from.gotxt @@ -164,7 +164,7 @@ then show_master_status_cmd="show binary log status" fi -$master_use_script -e "$show_master_status_cmd\G" > $master_status +$master_use_script --vertical -e "$show_master_status_cmd" > $master_status binlog_file=$(grep File < $master_status | awk '{print $2}') binlog_pos=$(grep Position < $master_status | awk '{print $2}') rm -f $master_status @@ -270,7 +270,7 @@ then stop_reset_cmd="stop replica; reset replica" fi $SBDIR/use -v -e "$start_replica_cmd" -$SBDIR/use -v -e "$show_replica_cmd\G" | grep "\(Running:\|Master_Log_Pos\|Source_Log_Pos\|\ $active_replication echo "Connected to $master_path" >> $active_replication echo "#!{{.ShellPath}}" > $remove_replication