blob: e2e4c0da4b02b01866fb2f0eff5036c22d9866ca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#!/bin/sh
# script to check accessibility to the reclock file on a node
[ -n "$CTDB_BASE" ] || \
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. "${CTDB_BASE}/functions"
load_script_options
ctdb_setup_state_dir "service" "reclock"
# If CTDB_RECOVERY_LOCK specifies a helper then exit because this
# script can't do anything useful.
case "$CTDB_RECOVERY_LOCK" in
!*) exit 0 ;;
esac
case "$1" in
init)
ctdb_counter_init
if [ -n "$CTDB_RECOVERY_LOCK" ] ; then
d=$(dirname "$CTDB_RECOVERY_LOCK")
mkdir -vp "$d"
fi
;;
monitor)
# Early exit if not using a reclock file
[ -n "$CTDB_RECOVERY_LOCK" ] || exit 0
# Try to stat the reclock file as a background process so that
# we don't block in case the cluster filesystem is unavailable
(
if stat "$CTDB_RECOVERY_LOCK" ; then
# We could stat the file, reset the counter
ctdb_counter_init
fi
) >/dev/null 2>&1 &
ctdb_counter_incr
num_fails=$(ctdb_counter_get)
if [ "$num_fails" -ge 200 ] ; then
echo "Reclock file \"$CTDB_RECOVERY_LOCK\" can not be accessed. Shutting down."
df
sleep 1
$CTDB shutdown
exit 1
elif [ "$num_fails" -ge 4 ] ; then
die "ERROR: ${num_fails} consecutive failures checking reclock"
fi
;;
esac
exit 0
|