mysql: improve shell syntax for mysql_skip script
Ansible Lint |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |2776|4|2772|5|:+1: Reference build: <a href="https://jenkins.evolix.org/job/gitea/job/ansible-roles/job/unstable/254//ansiblelint">Evolix » ansible-roles » unstable #254</a> Details
gitea/ansible-roles/pipeline/head This commit looks good Details

This commit is contained in:
Jérémy Lecour 2023-05-22 14:16:14 +02:00 committed by Jérémy Lecour
parent 7b667d1650
commit 8706a35705
2 changed files with 14 additions and 12 deletions

View File

@ -12,15 +12,18 @@ The **patch** part changes is incremented if multiple releases happen the same m
## [Unreleased]
### Added
* userlogrotate: rotate also php.log.
* nagios-nrpe: add a NRPE check-local command with completion.
### Changed
* elasticsearch: improve networking configuration
* evolinux-users: remove Stretch references in tasks that also apply to next Debian versions.
* evolinux-users: remove Stretch references in tasks that also apply to next Debian versions
* mysql: improve shell syntax for mysql_skip script
### Fixed
* packweb-apache,nagios-nrpe: add missing task and config for PHP 8.2 container
* potsfix: add missing `localhost.$mydomain` to mydestination

View File

@ -18,29 +18,28 @@ log_file="/var/log/mysql_skip.log"
mysql_skip_error() {
error="$1"
error="$(date --iso-8601=seconds) Skiping: $error"
printf "Skipping: $error\n"
mysql $mysql_opt -e 'SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE;'
mysql ${mysql_opt} -e 'SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE;'
[ -n "$log_file" ] && echo "$error" >>"$log_file"
printf 'Skipping: %s\n' "$error"
[ -n "$log_file" ] && printf '%s Skipping: %s\n' "$(date --iso-8601=seconds)" "$error" >>"$log_file"
}
while true; do
slave_status="$(mysql $mysql_opt -e 'SHOW SLAVE STATUS\G')"
seconds_behind_master=$(echo "$slave_status" |grep 'Seconds_Behind_Master: ' |awk -F ' ' '{print $2}')
last_SQL_error="$(echo "$slave_status" |grep 'Last_SQL_Error: ' |sed 's/^.\+Last_SQL_Error: //')"
slave_status="$(mysql ${mysql_opt} -e 'SHOW SLAVE STATUS\G')"
seconds_behind_master=$(echo "${slave_status}" |grep 'Seconds_Behind_Master: ' |awk -F ' ' '{print $2}')
last_SQL_error="$(echo "${slave_status}" |grep 'Last_SQL_Error: ' |sed 's/^.\+Last_SQL_Error: //')"
if [ "$seconds_behind_master" = "0" ]; then
if [ "${seconds_behind_master}" = "0" ]; then
#printf 'Replication is up to date!\n'
if [ "$exit_when_uptodate" = "true" ]; then
if [ "${exit_when_uptodate}" = "true" ]; then
exit 0
fi
elif [ -z "$last_SQL_error" ]; then
sleep $sleep_interval
sleep ${sleep_interval}
elif echo "$last_SQL_error" |grep -q -f $error_messages; then
mysql_skip_error "$last_SQL_error"
mysql_skip_error "${last_SQL_error}"
fi
sleep 1