From 69c6cb5dc4907c9133bb6f8077f35ad5eafb7549 Mon Sep 17 00:00:00 2001 From: Alexey Yurchenko Date: Sun, 19 May 2024 00:23:00 +0300 Subject: [PATCH] Fix recovering state GTID in case log file contains non-text bytes - use grep with -a option. Signed-off-by: Julius Goryavsky --- mysql-test/suite/galera/include/galera_wsrep_recover.inc | 4 ++-- mysql-test/suite/galera/t/galera_pc_recovery.test | 4 ++-- mysql-test/suite/wsrep/t/wsrep-recover-step.inc | 2 +- scripts/galera_recovery.sh | 4 ++-- scripts/mysqld_safe.sh | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mysql-test/suite/galera/include/galera_wsrep_recover.inc b/mysql-test/suite/galera/include/galera_wsrep_recover.inc index aa2f0e2e777..efe803dcc9f 100644 --- a/mysql-test/suite/galera/include/galera_wsrep_recover.inc +++ b/mysql-test/suite/galera/include/galera_wsrep_recover.inc @@ -10,8 +10,8 @@ if (!$wsrep_recover_additional) --perl use strict; - my $wsrep_start_position_str = "grep 'WSREP: Recovered position:' $ENV{MYSQL_TMP_DIR}/galera_wsrep_recover.log | sed 's/.*WSREP\:\ Recovered\ position://' | sed 's/^[ \t]*//'"; - my $wsrep_start_position = `grep 'WSREP: Recovered position:' $ENV{MYSQL_TMP_DIR}/galera_wsrep_recover.log | sed 's/.*WSREP\:\ Recovered\ position://' | sed 's/^[ \t]*//'`; + my $wsrep_start_position_str = "grep -a 'WSREP: Recovered position:' $ENV{MYSQL_TMP_DIR}/galera_wsrep_recover.log | sed 's/.*WSREP\:\ Recovered\ position://' | sed 's/^[ \t]*//'"; + my $wsrep_start_position = `grep -a 'WSREP: Recovered position:' $ENV{MYSQL_TMP_DIR}/galera_wsrep_recover.log | sed 's/.*WSREP\:\ Recovered\ position://' | sed 's/^[ \t]*//'`; chomp($wsrep_start_position); die if $wsrep_start_position eq ''; diff --git a/mysql-test/suite/galera/t/galera_pc_recovery.test b/mysql-test/suite/galera/t/galera_pc_recovery.test index 16abe6fc9ba..0fd9c8ab3d9 100644 --- a/mysql-test/suite/galera/t/galera_pc_recovery.test +++ b/mysql-test/suite/galera/t/galera_pc_recovery.test @@ -38,10 +38,10 @@ SELECT COUNT(*) = 1 FROM t1; --perl use strict; - my $wsrep_start_position1 = `grep 'WSREP: Recovered position:' $ENV{MYSQL_TMP_DIR}/galera_wsrep_recover.1.log | sed 's/.*WSREP\:\ Recovered\ position://' | sed 's/^[ \t]*//'`; + my $wsrep_start_position1 = `grep -a 'WSREP: Recovered position:' $ENV{MYSQL_TMP_DIR}/galera_wsrep_recover.1.log | sed 's/.*WSREP\:\ Recovered\ position://' | sed 's/^[ \t]*//'`; chomp($wsrep_start_position1); - my $wsrep_start_position2 = `grep 'WSREP: Recovered position:' $ENV{MYSQL_TMP_DIR}/galera_wsrep_recover.2.log | sed 's/.*WSREP\:\ Recovered\ position://' | sed 's/^[ \t]*//'`; + my $wsrep_start_position2 = `grep -a 'WSREP: Recovered position:' $ENV{MYSQL_TMP_DIR}/galera_wsrep_recover.2.log | sed 's/.*WSREP\:\ Recovered\ position://' | sed 's/^[ \t]*//'`; chomp($wsrep_start_position2); die if $wsrep_start_position1 eq '' || $wsrep_start_position2 eq ''; diff --git a/mysql-test/suite/wsrep/t/wsrep-recover-step.inc b/mysql-test/suite/wsrep/t/wsrep-recover-step.inc index 22669438fe0..b131ac07641 100644 --- a/mysql-test/suite/wsrep/t/wsrep-recover-step.inc +++ b/mysql-test/suite/wsrep/t/wsrep-recover-step.inc @@ -18,7 +18,7 @@ --perl use strict; - my $wsrep_start_position = `grep 'WSREP: Recovered position:' $ENV{MYSQL_TMP_DIR}/galera_wsrep_recover.log | sed 's/.*WSREP\:\ Recovered\ position://' | sed 's/^[ \t]*//'`; + my $wsrep_start_position = `grep -a 'WSREP: Recovered position:' $ENV{MYSQL_TMP_DIR}/galera_wsrep_recover.log | sed 's/.*WSREP\:\ Recovered\ position://' | sed 's/^[ \t]*//'`; chomp($wsrep_start_position); die if $wsrep_start_position eq ''; open(FILE, ">", "$ENV{MYSQL_TMP_DIR}/galera_wsrep_start_position.inc") or die; diff --git a/scripts/galera_recovery.sh b/scripts/galera_recovery.sh index 9ff5e4e5f50..50aeb3a0b91 100644 --- a/scripts/galera_recovery.sh +++ b/scripts/galera_recovery.sh @@ -81,10 +81,10 @@ wsrep_recover_position() { # Parse server's error log for recovered position. The server prints # "..skipping position recovery.." if started without wsrep. - recovered_pos="$(grep 'WSREP: Recovered position:' $log_file)" + recovered_pos="$(grep -a 'WSREP: Recovered position:' $log_file)" if [ -z "$recovered_pos" ]; then - skipped="$(grep WSREP $log_file | grep 'skipping position recovery')" + skipped="$(grep -a WSREP $log_file | grep 'skipping position recovery')" if [ -z "$skipped" ]; then log "WSREP: Failed to recover position: '`cat $log_file`'" exit 1 diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index be115066f80..074840e992d 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -260,9 +260,9 @@ wsrep_recover_position() { exit 1 fi - local rp="$(grep 'WSREP: Recovered position:' $wr_logfile)" + local rp="$(grep -a 'WSREP: Recovered position:' $wr_logfile)" if [ -z "$rp" ]; then - local skipped="$(grep WSREP $wr_logfile | grep 'skipping position recovery')" + local skipped="$(grep -a WSREP $wr_logfile | grep 'skipping position recovery')" if [ -z "$skipped" ]; then log_error "WSREP: Failed to recover position: '`cat $wr_logfile`'" ret=1