Rev 754: auto-run the vacuum and repack ops every 5 minutes by default in http://samba.org/~tridge/ctdb

tridge at samba.org tridge at samba.org
Wed Jan 9 23:04:04 GMT 2008


------------------------------------------------------------
revno: 754
revision-id:tridge at samba.org-20080109230403-8wfw2fs3v0cl6ox7
parent: tridge at samba.org-20080109224314-jng6hpo4lbo9y8ls
committer: Andrew Tridgell <tridge at samba.org>
branch nick: tridge.stable
timestamp: Thu 2008-01-10 10:04:03 +1100
message:
  auto-run the vacuum and repack ops every 5 minutes by default
modified:
  config/events.d/00.ctdb        events-20070529030121-04fjh63cxfh8v1pj-1
=== modified file 'config/events.d/00.ctdb'
--- a/config/events.d/00.ctdb	2007-10-29 01:34:45 +0000
+++ b/config/events.d/00.ctdb	2008-01-09 23:04:03 +0000
@@ -18,6 +18,18 @@
 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 @@
 	    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



More information about the samba-cvs mailing list