Skip to content

Commit

Permalink
fix: check ob init success
Browse files Browse the repository at this point in the history
  • Loading branch information
shanshanying committed Jan 4, 2024
1 parent 72dec3a commit 225c045
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions addons/oceanbase/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,17 @@ echo "Recovering: $RECOVERING"
init_port_list

function wait_for_observer_ready {
local RETRY_MAX=20
local retry_times=0
echo "Wait for observer on this node to be ready"
until nc -z 127.0.0.1 $COMP_MYSQL_PORT; do
echo "observer on this node is not ready, wait for a moment..."
sleep 3
retry_times=$(($retry_times+1))
sleep 5
if [ $retry_times -gt ${RETRY_MAX} ]; then
echo "Failed to start server ${KB_POD_IP}:$COMP_RPC_PORT exit..."
exit 1
fi
done
}

Expand Down Expand Up @@ -69,7 +77,7 @@ if [ "${ip_changed}" = "false" ] && [ "$RECOVERING" = "True" ]; then
sleep 10
done
create_ready_flag
sleep 3600000000
sleep infinity
fi

if [ $RECOVERING = "True" ]; then
Expand All @@ -94,7 +102,28 @@ if [ $RECOVERING = "True" ]; then
echo "Cluster is not healthy, fail to recover and join the cluster"
fi
else
echo "check if the server has been initialized"
wait_time=30 # wait up to 30 seconds
elapsed_time=0
filename=$OB_HOME_DIR/log/observer.log
while [ $elapsed_time -lt $wait_time ]; do
if grep -q 'success to start log pool' $filename; then
echo "oceanbase has been initialized successfully"
break
else
echo "oceanbase is not initialized yet, wait for it..."
sleep 1
elapsed_time=$((elapsed_time + 1))
fi
done

if [ $elapsed_time -ge $wait_time ]; then
echo "Failed to init server ${KB_POD_IP}:$COMP_RPC_PORT exit..."
exit 1
fi

echo "Creating readiness flag..."
# wait till it is running
create_ready_flag

echo "Resolving other servers' IPs"
Expand Down

0 comments on commit 225c045

Please sign in to comment.