Skip to content

Commit 47fb78c

Browse files
Punya Biswalsrowen
Punya Biswal
authored andcommitted
[SPARK-6952] Handle long args when detecting PID reuse
sbin/spark-daemon.sh used ps -p "$TARGET_PID" -o args= to figure out whether the process running with the expected PID is actually a Spark daemon. When running with a large classpath, the output of ps gets truncated and the check fails spuriously. This weakens the check to see if it's a java command (which is something we do in other parts of the script) rather than looking for the specific main class name. This means that SPARK-4832 might happen under a slightly broader range of circumstances (a java program happened to reuse the same PID), but it seems worthwhile compared to failing consistently with a large classpath. Author: Punya Biswal <pbiswal@palantir.com> Closes #5535 from punya/feature/SPARK-6952 and squashes the following commits: 7ea12d1 [Punya Biswal] Handle long args when detecting PID reuse
1 parent 6d3c4d8 commit 47fb78c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sbin/spark-daemon.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ case $option in
130130

131131
if [ -f $pid ]; then
132132
TARGET_ID="$(cat "$pid")"
133-
if [[ $(ps -p "$TARGET_ID" -o args=) =~ $command ]]; then
133+
if [[ $(ps -p "$TARGET_ID" -o comm=) =~ "java" ]]; then
134134
echo "$command running as process $TARGET_ID. Stop it first."
135135
exit 1
136136
fi
@@ -155,7 +155,7 @@ case $option in
155155
echo $newpid > $pid
156156
sleep 2
157157
# Check if the process has died; in that case we'll tail the log so the user can see
158-
if [[ ! $(ps -p "$newpid" -o args=) =~ $command ]]; then
158+
if [[ ! $(ps -p "$newpid" -o comm=) =~ "java" ]]; then
159159
echo "failed to launch $command:"
160160
tail -2 "$log" | sed 's/^/ /'
161161
echo "full log in $log"

0 commit comments

Comments
 (0)