Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] The FE&BE&CN startup script automatically detects that the startup is successful #48793

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

zhuxt2015
Copy link
Contributor

Why I'm doing:

What I'm doing:

Fixes #48369

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
  • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.3
    • 3.2
    • 3.1
    • 3.0
    • 2.5

echo "The startup time is more than $timeout seconds, the $process_name process may not start successfully!"
else
echo "This node does not have the curl command, please manually check whether the $process_name process is successfully started"
fi
else
exec $LIMIT $JAVA $final_java_opt com.starrocks.StarRocksFE ${HELPER} ${HOST_TYPE} "$@" </dev/null
fi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The most risky bug in this code is:
Potential race condition causing premature script exit.

You can modify the code like this:

# StarRocksFE java process will write its process id into $pidfile
if [ ${RUN_DAEMON} -eq 1 ]; then
    echo "The $process_name process is starting!"
    nohup $LIMIT $JAVA $final_java_opt com.starrocks.StarRocksFE ${HELPER} ${HOST_TYPE} "$@" &> /dev/null &

    pid=$!
    if command -v curl &>/dev/null; then
        timeout=30
        end_time=$((SECONDS + timeout))
        while [ $SECONDS -lt $end_time ]; do
            if check_health; then
                echo "The $process_name process has started successfully!"
                exit 0
            fi
            sleep 1
        done
        echo "The startup time is more than $timeout seconds, the $process_name process may not start successfully!"
        kill $pid # Ensure the process does not linger if startup fails
    else
        echo "This node does not have the curl command, please manually check whether the $process_name process is successfully started"
    fi
else
    exec $LIMIT $JAVA $final_java_opt com.starrocks.StarRocksFE ${HELPER} ${HOST_TYPE} "$@" </dev/null
fi

Copy link

[FE Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

conf_file="$STARROCKS_HOME/conf/cn.conf"
fi

http_port=$(grep -v ^# $conf_file |grep be_http_port| sed 's/.*= *//')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this already loaded by export_env_from_conf $STARROCKS_HOME/conf/cn.conf in line 72

@@ -206,14 +215,47 @@ fi
if [ ${RUN_LOG_CONSOLE} -eq 1 ] ; then
# force glog output to console (stderr)
export GLOG_logtostderr=1
else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't remove this, it'll break the assumption that crash core will be redirected to be.out/cn.out

fi

echo "start time: $(date), server uptime: $(uptime)"
check_health() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really tricky. I am inclined not to do so in start script. the --daemon is a simplest way to provide a daemonized launched solution, but usually it is not enough in production without watchdog. so A supervisor or systemd-service will be prefered to launch the service without --daemon and additional healthy/probing methods can be applied out of the start script and control whether need to restart/kill the process with supervisorctl restart <fe/be/cn> or systemctl restart <fe/be/cn>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The FE&BE&CN startup script automatically detects that the startup is successful
2 participants