From fc3bf3d3370a04a2017350e32be7390fce03ac3c Mon Sep 17 00:00:00 2001 From: Andrii Nikitin Date: Tue, 11 Jun 2024 13:00:13 +0200 Subject: [PATCH] Implement proper retry logic in ma-local/start --- product/ma/local/start.sh.m4 | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/product/ma/local/start.sh.m4 b/product/ma/local/start.sh.m4 index 0efc341..45c00b6 100644 --- a/product/ma/local/start.sh.m4 +++ b/product/ma/local/start.sh.m4 @@ -2,13 +2,10 @@ set -e [ -d __workdir/dt ] || mkdir __workdir/dt [ -f __datadir/ibdata1 ] || __workdir/init_datadir -/usr/sbin/mariadbd --datadir=__datadir --user=$USER --socket=__workdir/.sock --skip-networking --log-error=__workdir/.cerr --pid-file=__workdir/.pid "$@" & +eatmydata=$(which eatmydata 2>/dev/null) || : + +$eatmydata /usr/sbin/mariadbd --datadir=__datadir --user=$USER --socket=__workdir/.sock --skip-networking --log-error=__workdir/.cerr --pid-file=__workdir/.pid "$@" & sleep 0.1 -__workdir/status >& /dev/null || sleep 0.1 -__workdir/status >& /dev/null || sleep 0.1 -__workdir/status >& /dev/null || sleep 0.1 -__workdir/status >& /dev/null || sleep 0.1 -__workdir/status >& /dev/null || sleep 0.1 -__workdir/status >& /dev/null || sleep 0.1 -__workdir/status >& /dev/null || sleep 1 + +(r=150; while ! __workdir/status >& /dev/null ; do ((--r))||exit 1; sleep 0.1 ;done)