mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
ctdb-scripts: Run a single instance of debug_locks.sh at a give time
This prevents spamming of logs if multiple lock requests are waiting and keep timing out. Also, improve the logging format with separators. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Michael Adam <obnox@samba.org>
This commit is contained in:
parent
0eeb73c187
commit
86802b05f6
@ -14,15 +14,20 @@
|
|||||||
|
|
||||||
loadconfig ctdb
|
loadconfig ctdb
|
||||||
|
|
||||||
# Create sed expression to convert inodes to names
|
(
|
||||||
sed_cmd=$( ls -li "$CTDB_DBDIR"/*.tdb.* "$CTDB_DBDIR_PERSISTENT"/*.tdb.* |
|
flock -n 9 || exit 1
|
||||||
|
|
||||||
|
echo "===== Start of debug locks PID=$$ ====="
|
||||||
|
|
||||||
|
# Create sed expression to convert inodes to names
|
||||||
|
sed_cmd=$( ls -li "$CTDB_DBDIR"/*.tdb.* "$CTDB_DBDIR_PERSISTENT"/*.tdb.* |
|
||||||
sed -e "s#${CTDB_DBDIR}/\(.*\)#\1#" \
|
sed -e "s#${CTDB_DBDIR}/\(.*\)#\1#" \
|
||||||
-e "s#${CTDB_DBDIR_PERSISTENT}/\(.*\)#\1#" |
|
-e "s#${CTDB_DBDIR_PERSISTENT}/\(.*\)#\1#" |
|
||||||
awk '{printf "s#[0-9]*:[0-9]*:%s #%s #\n", $1, $10}' )
|
awk '{printf "s#[0-9]*:[0-9]*:%s #%s #\n", $1, $10}' )
|
||||||
|
|
||||||
# Parse /proc/locks and extract following information
|
# Parse /proc/locks and extract following information
|
||||||
# pid process_name tdb_name offsets [W]
|
# pid process_name tdb_name offsets [W]
|
||||||
out=$( cat /proc/locks |
|
out=$( cat /proc/locks |
|
||||||
grep -F "POSIX ADVISORY WRITE" |
|
grep -F "POSIX ADVISORY WRITE" |
|
||||||
awk '{ if($2 == "->") { print $6, $7, $8, $9, "W" } else { print $5, $6, $7, $8 } }' |
|
awk '{ if($2 == "->") { print $6, $7, $8, $9, "W" } else { print $5, $6, $7, $8 } }' |
|
||||||
while read pid rest ; do
|
while read pid rest ; do
|
||||||
@ -30,9 +35,9 @@ out=$( cat /proc/locks |
|
|||||||
echo $pid $pname $rest
|
echo $pid $pname $rest
|
||||||
done | sed -e "$sed_cmd" | grep "\.tdb" )
|
done | sed -e "$sed_cmd" | grep "\.tdb" )
|
||||||
|
|
||||||
if [ -n "$out" ]; then
|
if [ -n "$out" ]; then
|
||||||
# Log information about locks
|
# Log information about locks
|
||||||
echo "$out" | logger -t "ctdbd-lock"
|
echo "$out"
|
||||||
|
|
||||||
# Find processes that are waiting for locks
|
# Find processes that are waiting for locks
|
||||||
dbs=$(echo "$out" | grep "W$" | awk '{print $3}')
|
dbs=$(echo "$out" | grep "W$" | awk '{print $3}')
|
||||||
@ -45,9 +50,14 @@ if [ -n "$out" ]; then
|
|||||||
|
|
||||||
# For each process waiting, log stack trace
|
# For each process waiting, log stack trace
|
||||||
for pid in $pids ; do
|
for pid in $pids ; do
|
||||||
gstack $pid | logger -t "ctdbd-lock $pid"
|
echo "----- Stack trace for PID=$pid -----"
|
||||||
# gcore -o /var/log/core-deadlock-ctdb $pid
|
gstack $pid
|
||||||
|
# gcore -o /var/log/core-deadlock-ctdb $pid
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "===== End of debug locks PID=$$ ====="
|
||||||
|
|
||||||
|
) 9>"${CTDB_VARDIR}/debug_locks.lock" | script_log "ctdbd-lock"
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user