3 [ -n "$CTDB_BASE" ] || \
4 export CTDB_BASE
=$
(cd -P $
(dirname "$0") ; echo "$PWD")
6 .
"$CTDB_BASE/functions"
11 if [ -n "$CTDB_DEBUG_HUNG_SCRIPT_LOGFILE" ] ; then
12 exec >>"$CTDB_DEBUG_HUNG_SCRIPT_LOGFILE" 2>&1
16 flock
--wait 2 9 ||
exit 1
18 echo "===== Start of hung script debug for PID=\"$1\", event=\"$2\" ====="
20 echo "pstree -p -a ${1}:"
21 out
=$
(pstree
-p -a $1)
24 # Check for processes matching a regular expression and print
25 # stack staces. This could help confirm that certain processes
26 # are stuck in certain places such as the cluster filesystem. The
27 # regexp should separate items with "\|" and should not contain
28 # parentheses. The default pattern can be replaced for testing.
29 default_pat
='exportfs\|rpcinfo'
30 pat
="${CTDB_DEBUG_HUNG_SCRIPT_STACKPAT:-${default_pat}}"
32 sed -n "s@.*-\(.*${pat}.*\),\([0-9]*\).*@\2 \1@p" |
33 while read pid name
; do
34 trace
=$
(cat "/proc/${pid}/stack" 2>/dev
/null
)
35 if [ $?
-eq 0 ] ; then
36 echo "---- Stack trace of interesting process ${pid}[${name}] ----"
41 if [ "$2" = "init" ] ; then
45 echo "---- ctdb scriptstatus ${2}: ----"
46 # No use running several of these in parallel if, say, "releaseip"
47 # event hangs for multiple IPs. In that case the output would be
48 # interleaved in the log and would just be confusing.
49 ctdb scriptstatus
"$2"
51 echo "===== End of hung script debug for PID=\"$1\", event=\"$2\" ====="
53 ) 9>"${CTDB_VARDIR}/debug-hung-script.lock"