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
Prevent init script from returning when the service isn't actually started #6909
Conversation
@spinscale please could you take a look |
With all the tests i do with the packages and init scripts i have never seen this sort of race condition happen. |
i=0 | ||
timeout=10 | ||
# Wait for the process to be properly started before exiting | ||
until { cat "$PID_FILE" | xargs kill -0; } >/dev/null 2>&1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line seems weird to me. You're sending a kill -0 signal to check if a process with the PID exists, but the PID_FILE will only exist if the process has started because it is that process which writes the PID_FILE... What are you trying to achieve here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the PID file doesn't exist, xargs kill returns 123 so the loop keeps going.
@sbraz Have you seen this problem occur, or is this a theoretical concern? |
I have seen it occur when I started ElasticSearch with Pacemaker, it would sometimes start ES, check its status and find it stopped. |
…sn't actually started. Close #6909
Sorry for the delay, but I just merged this PR. Thanks! |
Hello,
Since the init script uses start-stop-daemon's
-b
option, it might return from start before the service is actually started. If the init script's status action is called immediately after that, It will returnelasticsearch is not running
and exit with a non-zero code.This causes systems like Heartbeat to incorrectly start multiple instances of Elasticsearch at once.
This pull request aims at fixing this issue by waiting until the Elasticsearch process is started.
There might be a nicer way to achieve this but this is what came to mind.