summaryrefslogtreecommitdiffstats
path: root/ctdb
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2008-01-10 10:04:03 +1100
committerAndrew Tridgell <tridge@samba.org>2008-01-10 10:04:03 +1100
commit624898bd819e1561c7afb373c62a7ef83a4ddf28 (patch)
tree8b7e03b91f9c7ddeb5028a6d534590e8eda7b1fa /ctdb
parent3b3fceacbe3dd1f0ed0a1ddc3b529e62f92ef146 (diff)
downloadsamba-624898bd819e1561c7afb373c62a7ef83a4ddf28.tar.gz
samba-624898bd819e1561c7afb373c62a7ef83a4ddf28.tar.xz
samba-624898bd819e1561c7afb373c62a7ef83a4ddf28.zip
auto-run the vacuum and repack ops every 5 minutes by default
(This used to be ctdb commit 3fc3f3d15a0f51811b32ff7b554d1f8ce9715358)
Diffstat (limited to 'ctdb')
-rwxr-xr-xctdb/config/events.d/00.ctdb25
1 files changed, 25 insertions, 0 deletions
diff --git a/ctdb/config/events.d/00.ctdb b/ctdb/config/events.d/00.ctdb
index fc82dbfac9..001544e5e8 100755
--- a/ctdb/config/events.d/00.ctdb
+++ b/ctdb/config/events.d/00.ctdb
@@ -18,6 +18,18 @@ PATH=/bin:/usr/bin:$PATH
cmd="$1"
shift
+# set default samba cleanup period - in minutes
+[ -z "$CTDB_VACUUM_PERIOD" ] && {
+ CTDB_VACUUM_PERIOD=5
+}
+
+###########################
+# periodic vacuum function
+periodic_vacuum() {
+ # this cleans up dead records and repacks the databases
+ ( time ctdb vacuum 200000 -T 30; time ctdb repack -T 30 ) > $CTDB_BASE/state/vacuum.log 2>&1 &
+}
+
case $cmd in
startup)
# make sure we have a blank state directory for the scripts to work with
@@ -33,6 +45,19 @@ case $cmd in
echo "`date` Set $varname to $value"
done || exit 1
;;
+
+ monitor)
+ # Create a dummy file to track when we need to do periodic cleanup
+ # of samba databases
+ [ -f $CTDB_BASE/state/periodic_vacuum ] || {
+ touch $CTDB_BASE/state/periodic_vacuum
+ }
+ [ `/usr/bin/find $CTDB_BASE/state/periodic_vacuum -mmin +$CTDB_VACUUM_PERIOD | wc -l` -eq 1 ] && {
+ # vacuum the databases
+ touch $CTDB_BASE/state/periodic_vacuum
+ periodic_vacuum
+ }
+
esac
# all OK