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

HBASE-27651 hbase-daemon.sh foreground_start should propagate SIGHUP and SIGTERM #5035

Merged
merged 2 commits into from
Mar 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions bin/hbase-daemon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,34 @@ hbase_rotate_log ()
fi
}

cleanAfterRun() {
if [ -f ${HBASE_PID} ]; then
# If the process is still running time to tear it down.
kill -9 `cat ${HBASE_PID}` > /dev/null 2>&1
rm -f ${HBASE_PID} > /dev/null 2>&1
function sighup_handler
{
# pass through SIGHUP if we can
if [ -f "${HBASE_PID}" ] ; then
kill -s HUP "$(cat "${HBASE_PID}")"
Copy link
Contributor

Choose a reason for hiding this comment

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

You'd rather see the output than /dev/null it? And does the old pid stick around now?

Copy link
Member Author

Choose a reason for hiding this comment

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

Testing in a docker container that disappears... I'm guessing that this script already handles the pid file, but let me look more closely...

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh. cleanupAfterRun handles the pid file.

fi
}

if [ -f ${HBASE_ZNODE_FILE} ]; then
if [ "$command" = "master" ]; then
HBASE_OPTS="$HBASE_OPTS $HBASE_MASTER_OPTS" $bin/hbase master clear > /dev/null 2>&1
function sigterm_handler
{
if [ -f "${HBASE_PID}" ]; then
kill -s TERM "$(cat "${HBASE_PID}")"
waitForProcessEnd "$(cat "${HBASE_PID}")" "${command}"
fi
cleanAfterRun
}

cleanAfterRun() {
rm -f "${HBASE_PID}" > /dev/null 2>&1
if [ -f "${HBASE_ZNODE_FILE}" ]; then
if [ "${command}" = "master" ]; then
HBASE_OPTS="$HBASE_OPTS $HBASE_MASTER_OPTS" "${bin}/hbase" master clear > /dev/null 2>&1
else
#call ZK to delete the node
ZNODE=`cat ${HBASE_ZNODE_FILE}`
HBASE_OPTS="$HBASE_OPTS $HBASE_REGIONSERVER_OPTS" $bin/hbase zkcli delete ${ZNODE} > /dev/null 2>&1
# call ZK to delete the node
ZNODE="$(cat "${HBASE_ZNODE_FILE}")"
HBASE_OPTS="$HBASE_OPTS $HBASE_REGIONSERVER_OPTS" "${bin}/hbase" zkcli delete "${ZNODE}" > /dev/null 2>&1
fi
rm ${HBASE_ZNODE_FILE}
rm -f "${HBASE_ZNODE_FILE}" > /dev/null 2>&1
fi
}

Expand Down Expand Up @@ -225,7 +237,9 @@ case $startStop in
;;

(foreground_start)
trap cleanAfterRun SIGHUP SIGINT SIGTERM EXIT
trap sighup_handler HUP
trap sigterm_handler INT TERM EXIT

if [ "$HBASE_NO_REDIRECT_LOG" != "" ]; then
# NO REDIRECT
echo "`date` Starting $command on `hostname`"
Expand Down