[SCM] CTDB repository - branch 2.5 updated - ctdb-2.5.4-103-g46069f5

Amitay Isaacs amitay at samba.org
Fri Mar 6 00:09:50 MST 2015


The branch, 2.5 has been updated
       via  46069f56c93d986e173e0e0fba7e5162c7271609 (commit)
       via  730b06ea1f6eb1066bb6b8ac17a348c8570a9d2e (commit)
       via  505fda403fc1c1e440ae0edb1cf3e67ad8ed3a50 (commit)
       via  1d1711e940397d21e6803bce627f2b57c22c6b92 (commit)
       via  e5d543ad2576b3a0a7848e92082ac46f57012082 (commit)
       via  315df0148bb90a9641e4f55ec63c26cee9d062e7 (commit)
       via  46d5a7dcbb64e2055d8c427d646f12a878c89c07 (commit)
       via  86409b0888a6770478cb716e0aef187d6c559c3e (commit)
       via  5224e55f64f904cd1923d935251c6d74b7da6413 (commit)
       via  d2fcd86c64e3e74453784a2a203c8ea2449ce85b (commit)
       via  d46a2f8b371720a6b0c2afed27b0cb333c58c132 (commit)
       via  2234f7cf47018c3bb241e051d20617ffbfc6a198 (commit)
       via  e9dd5b649a25691a0771ed094650a945fecd4f54 (commit)
       via  d444570bfa7720c6413dee03556230f19fbf4623 (commit)
       via  67afd68f025852e5da5a60c25e09be8233ecba73 (commit)
      from  ccddcec6258f511511abe6861fe8347360d8a066 (commit)

https://git.samba.org/?p=ctdb.git;a=shortlog;h=2.5


- Log -----------------------------------------------------------------
commit 46069f56c93d986e173e0e0fba7e5162c7271609
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Feb 9 12:04:41 2015 +1100

    Change default debug level to NOTICE (2)
    
    This was true for the daemon until commit
    b4589b954e1090a934fafd3f8e3c2cf1ed785c61.
    
    Defaulting to ERR in the ctdb CLI tool encourages logging notices at
    ERR level, so default to NOTICE instead.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit 664d62b61108657d3011cf0bcbe260533c97676f)

commit 730b06ea1f6eb1066bb6b8ac17a348c8570a9d2e
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Mar 6 11:36:18 2015 +1100

    tests: Check for readable, not executable, script
    
    Scripts in eventscript unit tests are run under an explicitly
    specified shell so they do not need to be executable.  Checking that
    the script is executable breaks on scripts that are installed without
    the execute bit set, such as disabled eventscripts.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
    Autobuild-Date(master): Fri Mar  6 04:40:07 CET 2015 on sn-devel-104
    
    (Imported from commit f6efe0c5c2378f477e528ac9c6571a732aa2c49b)

commit 505fda403fc1c1e440ae0edb1cf3e67ad8ed3a50
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Mar 4 15:36:05 2015 +1100

    locking: Back-off from logging every 10 seconds
    
    If ctdb_lock_helper cannot get a lock within 10 seconds, ctdb daemon
    logs a message and invokes an external debug script.  This is repeated
    every 10 seconds.
    
    In case of a contention or on a loaded system, there can be multiple
    ctdb_lock_helper processes waiting to get lock on record(s).  For each
    lock request taking longer, ctdb daemon will flood the log every
    10 seconds.  Instead of logging aggressively every 10 seconds, relax
    logging to every 100s and 1000s if the elapsed time has exceeded 100s
    and 1000s respectively.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Michael Adam <obnox at samba.org>
    
    Autobuild-User(master): Michael Adam <obnox at samba.org>
    Autobuild-Date(master): Thu Mar  5 12:06:44 CET 2015 on sn-devel-104
    
    (Imported from commit 3f97be6d0fc166ccc3c97b7f71a01a4f9adb5ddd)

commit 1d1711e940397d21e6803bce627f2b57c22c6b92
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Mar 5 13:11:46 2015 +1100

    tests: Correctly cascade test failures from the end of pipes
    
    Some eventscript unit test failures get lost because _passed=false is
    set in the tail of a pipe.  Add a new function test_fail() and call it
    when necessary to ensure the value of _passed is set correctly.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Pair-programmed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    Autobuild-User(master): Martin Schwenke <martins at samba.org>
    Autobuild-Date(master): Thu Mar  5 07:16:54 CET 2015 on sn-devel-104
    
    (Imported from commit 956d1dbfd91615032de337b0d84b40c16657b8c1)

commit e5d543ad2576b3a0a7848e92082ac46f57012082
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Mar 5 13:10:32 2015 +1100

    scripts: Add a 'rm' stub so statd-callout tests work correctly
    
    statd-callout tries to remove global files from /var/lib/nfs/statd and
    this causes errors in tests.  Add an rm stub that ignores attempts to
    remove these files but invokes /bin/rm for anything else.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Pair-programmed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 956e51707d7ddcff060352f54d11ff42bdcc51ef)

commit 315df0148bb90a9641e4f55ec63c26cee9d062e7
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Feb 13 15:42:20 2015 +1100

    scripts: Remove unused function nfs_statd_update()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit 50ddc2c35643389c2f249c6ad4496ab73a1bfc99)

commit 46d5a7dcbb64e2055d8c427d646f12a878c89c07
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Feb 13 20:55:43 2015 +1100

    scripts: Change statd-callout to be more scalable
    
    Updating ctdb.tdb on each add-client, del-client and each delete
    during notify was too ambitious.  Persistent transactions do not
    perform well enough to do this.
    
    Revert to having add-client and del-client create touch files.  Each
    monitor event calls "statd-callout update" to convert touch files into
    ctdb.tdb records.
    
    Update testcases to do the "update" and add an extra test.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Pair-programmed-with: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit 500c6e194babe06b6aead7a053a9442c94db6e38)

commit 86409b0888a6770478cb716e0aef187d6c559c3e
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Feb 26 15:34:51 2015 +1100

    scripts: Fix a regression in statd-callout
    
    Commit 4638010abb116aed0c180207aaa11475277aecb7 changed from using
    gensub() to gsub() in awk.  However, it didn't halve the number of
    backslashes in the target strings.  This is necessary because
    backslash is used in gensub() target strings to allow substitution of
    text matching parenthesised subexpressions.  This is not the case with
    gsub().
    
    So, halve the number of backslashes in the target string where gsub()
    is used in statd-callout.  This is the only target string broken by
    changes made by the above commit
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit 032441d9a2974584cde455e4dbd5cc33fe6a23c2)

commit 5224e55f64f904cd1923d935251c6d74b7da6413
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Mar 4 11:51:20 2015 +1100

    tests: Unit tests for statd-callout
    
    With improvements to unit test infrastructure to support.  This
    includes linking the real statd-callout into etc-ctdb/ in place of the
    placeholder script.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit 22602f76bc1ec91e807a8f1cd45ba6fb4c05e622)

commit d2fcd86c64e3e74453784a2a203c8ea2449ce85b
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Feb 27 15:20:56 2015 +1100

    tests: Make setup of public addresses more obvious
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit d98c7ba382189161c5b8cbbebbdfbe36f1456572)

commit d46a2f8b371720a6b0c2afed27b0cb333c58c132
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Feb 27 15:19:04 2015 +1100

    tests: Extend eventscript unit test infrastructure for other scripts
    
    There's so much infrastructure here that it would be a shame not to
    use it for testing things like statd-callout.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit 7e7c24ca7a422f2258962216b0184eda8d49827f)

commit 2234f7cf47018c3bb241e051d20617ffbfc6a198
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Feb 27 15:17:30 2015 +1100

    tests: Support testing scripts that change directory
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit 9317d82c19a0eb51ff6293d00328a5c36b063a2c)

commit e9dd5b649a25691a0771ed094650a945fecd4f54
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Feb 27 15:15:18 2015 +1100

    tests: Extend ctdb stub to support "ip" with and without -X
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit 2aeb518637af29da03984470d874b94dfb18e34e)

commit d444570bfa7720c6413dee03556230f19fbf4623
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Feb 27 15:13:23 2015 +1100

    tests: Extend ctdb stub to support "ptrans", "pdelete", "catdb"
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit d057ca04a9eec0f2aa3d792da0a4648e3716685a)

commit 67afd68f025852e5da5a60c25e09be8233ecba73
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Aug 12 14:29:34 2014 +1000

    test: Remove unused function check_ctdb_logfile()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit 85cc4efbff601dc25a351ec838de168eb3c7d29a)

-----------------------------------------------------------------------

Summary of changes:
 common/cmdline.c                                   |   2 +-
 config/ctdb.sysconfig                              |   4 +-
 config/events.d/60.ganesha                         |   1 +
 config/events.d/60.nfs                             |   1 +
 config/functions                                   |  27 ++--
 config/statd-callout                               | 142 ++++++++++--------
 doc/ctdb.1.xml                                     |   2 +-
 doc/ctdbd.1.xml                                    |   6 +-
 doc/ctdbd.conf.5.xml                               |   2 +-
 server/ctdb_lock.c                                 |  20 ++-
 tests/INSTALL                                      |   2 +-
 tests/eventscripts/etc-ctdb/statd-callout          |   6 +-
 tests/eventscripts/scripts/local.sh                | 163 ++++++++++++++++-----
 tests/eventscripts/statd-callout.001.sh            |  15 ++
 tests/eventscripts/statd-callout.002.sh            |  16 ++
 tests/eventscripts/statd-callout.003.sh            |  18 +++
 tests/eventscripts/statd-callout.004.sh            |  19 +++
 tests/eventscripts/statd-callout.005.sh            |  27 ++++
 tests/eventscripts/statd-callout.006.sh            |  29 ++++
 tests/eventscripts/statd-callout.007.sh            |  16 ++
 tests/eventscripts/stubs/ctdb                      | 129 +++++++++++++---
 tests/eventscripts/stubs/id                        |   3 +
 tests/eventscripts/stubs/rm                        |   6 +
 .../stubs/ssh => eventscripts/stubs/smnotify}      |   1 +
 tests/scripts/common.sh                            |   4 +
 tests/scripts/unit.sh                              |   6 +
 26 files changed, 513 insertions(+), 154 deletions(-)
 mode change 100755 => 120000 tests/eventscripts/etc-ctdb/statd-callout
 create mode 100755 tests/eventscripts/statd-callout.001.sh
 create mode 100755 tests/eventscripts/statd-callout.002.sh
 create mode 100755 tests/eventscripts/statd-callout.003.sh
 create mode 100755 tests/eventscripts/statd-callout.004.sh
 create mode 100755 tests/eventscripts/statd-callout.005.sh
 create mode 100755 tests/eventscripts/statd-callout.006.sh
 create mode 100755 tests/eventscripts/statd-callout.007.sh
 create mode 100755 tests/eventscripts/stubs/id
 create mode 100755 tests/eventscripts/stubs/rm
 copy tests/{onnode/stubs/ssh => eventscripts/stubs/smnotify} (62%)


Changeset truncated at 500 lines:

diff --git a/common/cmdline.c b/common/cmdline.c
index cd59d84..ca214b4 100644
--- a/common/cmdline.c
+++ b/common/cmdline.c
@@ -35,7 +35,7 @@ static struct {
 	const char *events;
 } ctdb_cmdline = {
 	.torture = 0,
-	.debuglevel = "ERR",
+	.debuglevel = "NOTICE",
 };
 
 enum {OPT_EVENTSYSTEM=1};
diff --git a/config/ctdb.sysconfig b/config/ctdb.sysconfig
index d96fb8e..a819219 100644
--- a/config/ctdb.sysconfig
+++ b/config/ctdb.sysconfig
@@ -26,8 +26,8 @@ CTDB_PUBLIC_ADDRESSES=/etc/ctdb/public_addresses
 # CTDB_LOGFILE=/var/log/log.ctdb
 # CTDB_SYSLOG=no
 
-# Default log level is ERR.  NOTICE is a little more verbose.
-CTDB_DEBUGLEVEL=NOTICE
+# Default log level is NOTICE.  Want less logging?
+# CTDB_DEBUGLEVEL=ERR
 
 # Set some CTDB tunable variables during CTDB startup?
 # CTDB_SET_TraverseTimeout=60
diff --git a/config/events.d/60.ganesha b/config/events.d/60.ganesha
index be77e1d..1f47d6f 100755
--- a/config/events.d/60.ganesha
+++ b/config/events.d/60.ganesha
@@ -221,6 +221,7 @@ case "$1" in
 	} || exit $?
 
 	update_tickles 2049
+	nfs_update_lock_info
 
 	# check that statd responds to rpc requests
 	# if statd is not running we try to restart it
diff --git a/config/events.d/60.nfs b/config/events.d/60.nfs
index c4e798e..d570cd7 100755
--- a/config/events.d/60.nfs
+++ b/config/events.d/60.nfs
@@ -91,6 +91,7 @@ case "$1" in
 	} || exit $?
 
 	update_tickles 2049
+	nfs_update_lock_info
 
 	nfs_check_rpc_services
 
diff --git a/config/functions b/config/functions
index a41c195..864b7d5 100755
--- a/config/functions
+++ b/config/functions
@@ -680,6 +680,16 @@ get_tcp_connections_for_ip ()
 	 {print $4" "$5}'
 }
 
+##################################################################
+# use statd-callout to update NFS lock info
+##################################################################
+nfs_update_lock_info ()
+{
+    if [ -x "$CTDB_BASE/statd-callout" ] ; then
+	"$CTDB_BASE/statd-callout" update
+    fi
+}
+
 ########################################################
 # start/stop the Ganesha nfs service
 ########################################################
@@ -822,23 +832,6 @@ startstop_nfslock() {
 	esac
 }
 
-# Periodically update the statd database
-nfs_statd_update ()
-{
-    _update_period="$1"
-
-    _statd_update_trigger="$service_state_dir/update-trigger"
-    [ -f "$_statd_update_trigger" ] || touch "$_statd_update_trigger"
-
-    _last_update=$(stat --printf="%Y" "$_statd_update_trigger")
-    _current_time=$(date +"%s")
-    if [ $(( $_current_time - $_last_update)) -ge $_update_period ] ; then
-	touch "$_statd_update_trigger"
-	$CTDB_BASE/statd-callout updatelocal &
-	$CTDB_BASE/statd-callout updateremote &
-    fi
-}
-
 ########################################################
 
 add_ip_to_iface ()
diff --git a/config/statd-callout b/config/statd-callout
index e2a955e..4a331ac 100755
--- a/config/statd-callout
+++ b/config/statd-callout
@@ -30,7 +30,19 @@ loadconfig nfs
 nl="
 "
 
+ctdb_setup_service_state_dir "statd-callout"
+
+cd "$service_state_dir" || \
+    die "Failed to change directory to \"${service_state_dir}\""
+
 case "$1" in
+    # Keep a single file to keep track of the last "add-client" or
+    # "del-client'.  These get pushed to ctdb.tdb during "update",
+    # which will generally be run once each "monitor" cycle.  In this
+    # way we avoid scalability problems with flood of persistent
+    # transactions after a "notify" when all the clients re-take their
+    # locks.
+
     add-client)
 	# statd does not tell us to which IP the client connected so
 	# we must add it to all the IPs that we serve
@@ -38,42 +50,47 @@ case "$1" in
 	pnn=$(ctdb xpnn | sed -e 's/.*://')
 	date=$(date '+%s')
 	ctdb ip -X |
-	tail -n +2 | {
-	    # This all needs to be in the end of the pipe so it
-	    # doesn't get lost
-	    items=""
-	    while IFS="|" read x sip node x ; do
-		[ "$node" = "$pnn" ] || continue # not us
-		key="statd-state@${sip}@${cip}"
-		item="\"${key}\" \"${date}\""
-		items="${items}${items:+${nl}}${item}"
-	    done
-	    if ! echo "$items" | ctdb ptrans "ctdb.tdb" ; then
-		die "Failed to add clients"
-	    fi
-	}
+	tail -n +2 |
+	while IFS="|" read x sip node x ; do
+	    [ "$node" = "$pnn" ] || continue # not us
+	    key="statd-state@${sip}@${cip}"
+	    echo "\"${key}\" \"${date}\"" >"$key"
+	done
 	;;
-  del-client)
+
+    del-client)
 	# statd does not tell us from which IP the client disconnected
 	# so we must add it to all the IPs that we serve
 	cip="$2"
 	pnn=$(ctdb xpnn | sed -e 's/.*://')
 	ctdb ip -X |
-	tail -n +2 | {
-	    # This all needs to be in the end of the pipe so it
-	    # doesn't get lost
-	    items=""
-	    while IFS="|" read x sip node x ; do
-		[ "$node" = "$pnn" ] || continue # not us
-		key="statd-state@${sip}@${cip}"
-		item="\"${key}\" \"\""
-		items="${items}${items:+${nl}}${item}"
-	    done
-	    if ! echo "$items" | ctdb ptrans "ctdb.tdb" ; then
-		die "Failed to delete clients"
-	    fi
-	}
+	tail -n +2 |
+	while IFS="|" read x sip node x ; do
+	    [ "$node" = "$pnn" ] || continue # not us
+	    key="statd-state@${sip}@${cip}"
+	    echo "\"${key}\" \"\"" >"$key"
+	done
 	;;
+
+    update)
+        files=$(echo statd-state@*)
+	if [ "$files" = "statd-state@*" ] ; then
+	    # No files!
+	    exit 0
+	fi
+	# Filter out lines for any IP addresses that are not currently
+	# hosted public IP addresses.
+	pnn=$(ctdb xpnn | sed -e 's/.*://')
+	ctdb_ips=$(ctdb ip | tail -n +2)
+	sed_expr=$(echo "$ctdb_ips" |
+	    awk -v pnn=$pnn 'pnn == $2 { \
+                ip = $1; gsub(/\./, "\\.", ip); \
+                printf "/statd-state@%s@/p\n", ip }')
+        if cat $files | sed -n "$sed_expr" | ctdb ptrans "ctdb.tdb" ; then
+            rm $files
+	fi
+        ;;
+
     notify)
 	# we must restart the lockmanager (on all nodes) so that we get
 	# a clusterwide grace period (so other clients dont take out
@@ -144,42 +161,51 @@ case "$1" in
 	# Construct a sed expression to take catdb output and produce pairs of:
 	#   server-IP client-IP
 	# but only for the server-IPs that are hosted on this node.
-	sed_expr=$(ctdb ip | tail -n +2 |
+	ctdb_all_ips=$(ctdb ip -n all | tail -n +2)
+	sed_expr=$(echo "$ctdb_all_ips" |
 	    awk -v pnn=$pnn 'pnn == $2 { \
-                ip = $1; gsub(/\./, "\\\\.", ip); \
+                ip = $1; gsub(/\./, "\\.", ip); \
                 printf "s/^key.*=.*statd-state@\\(%s\\)@\\([^\"]*\\).*/\\1 \\2/p\n", ip }')
 
 	statd_state=$(ctdb catdb ctdb.tdb | sed -n "$sed_expr" | sort)
 	[ -n "$statd_state" ] || exit 0
 
-	# The following is dangerous if this script times out before
-	# all of the smnotify commands are run.  Revert to individual
-	# pdelete commands for now and consider optimising smnotify to
-	# read all the data from stdin and then run it in the
-	# background.
-	#
-	# Delete all the items from the TDB
-	#if ! echo "$statd_state" | \
-	#    awk '{ printf "\"statd-state@%s@%s\" \"\"\n", $1, $2 }') | \
-	#    ctdb ptrans ctdb.tdb ; then
+	prev=""
+	echo "$statd_state" | {
+	    # This all needs to be in the same command group at the
+	    # end of the pipe so it doesn't get lost when the loop
+	    # completes.
+	    items=""
+	    while read sip cip ; do
+		# Collect item to delete from the DB
+		key="statd-state@${sip}@${cip}"
+		item="\"${key}\" \"\""
+		items="${items}${items:+${nl}}${item}"
 
-	#    die "Yikes!"
-	#fi
+		# NOTE: Consider optimising smnotify to read all the
+		# data from stdin and then run it in the background.
+
+		# Reset stateval for each serverip
+		[ "$sip" = "$prev" ] || stateval="$state_even"
+		# Send notifies for server shutdown
+		smnotify --client=$cip --ip=$sip --server=$sip --stateval=$stateval
+		smnotify --client=$cip --ip=$sip --server=$NFS_HOSTNAME --stateval=$stateval
+		# Send notifies for server startup
+		stateval=$(($stateval + 1))
+		smnotify --client=$cip --ip=$sip --server=$sip --stateval=$stateval
+		smnotify --client=$cip --ip=$sip --server=$NFS_HOSTNAME --stateval=$stateval
+	    done
 
-	prev=""
-	echo "$statd_state" |
-	while read sip cip ; do
-	    # Delete the entry from the DB
-	    ctdb pdelete ctdb.tdb "statd-state@${sip}@${cip}"
-	    # Reset stateval for each serverip
-	    [ "$sip" = "$prev" ] || stateval="$state_even"
-	    # Send notifies for server shutdown
-	    smnotify --client=$cip --ip=$sip --server=$sip --stateval=$stateval
-	    smnotify --client=$cip --ip=$sip --server=$NFS_HOSTNAME --stateval=$stateval
-	    # Send notifies for server startup
-	    stateval=$(($stateval + 1))
-	    smnotify --client=$cip --ip=$sip --server=$sip --stateval=$stateval
-	    smnotify --client=$cip --ip=$sip --server=$NFS_HOSTNAME --stateval=$stateval
-	done
+	    echo "$items" | ctdb ptrans "ctdb.tdb"
+	}
+
+	# Remove any stale touch files (i.e. for IPs not currently
+	# hosted on this node and created since the last "update").
+	# There's nothing else we can do with them at this stage.
+	echo "$ctdb_all_ips" |
+	    awk -v pnn=$pnn 'pnn != $2 { print $1 }' |
+	    while read sip ; do
+		rm -f "statd-state@${sip}@"*
+	    done
 	;;
 esac
diff --git a/doc/ctdb.1.xml b/doc/ctdb.1.xml
index ccd46d6..ead860a 100644
--- a/doc/ctdb.1.xml
+++ b/doc/ctdb.1.xml
@@ -206,7 +206,7 @@
       <varlistentry><term>-d --debug=<parameter>DEBUGLEVEL</parameter></term>
       <listitem>
 	<para>
-	  Change the debug level for the command. Default is ERR (0).
+	  Change the debug level for the command. Default is NOTICE (2).
 	</para>
       </listitem>
       </varlistentry>
diff --git a/doc/ctdbd.1.xml b/doc/ctdbd.1.xml
index 080f506..56309a4 100644
--- a/doc/ctdbd.1.xml
+++ b/doc/ctdbd.1.xml
@@ -50,10 +50,8 @@
 	<term>-d, --debug=<parameter>DEBUGLEVEL</parameter></term>
 	<listitem>
 	  <para>
-	    This option sets the debug level to DEBUGLEVEL, which
-	    controls what will be written to the logfile. The default is
-	    0 which will only log important events and errors. A larger
-	    number will provide additional logging.
+	    This option sets the debug level to DEBUGLEVEL, which controls
+	    what will be written to the logfile. The default is 2.
 	  </para>
 	  <para>
 	    See the <citetitle>DEBUG LEVELS</citetitle> section in
diff --git a/doc/ctdbd.conf.5.xml b/doc/ctdbd.conf.5.xml
index a99ae9b..9067aed 100644
--- a/doc/ctdbd.conf.5.xml
+++ b/doc/ctdbd.conf.5.xml
@@ -202,7 +202,7 @@
 	<term>CTDB_DEBUGLEVEL=<parameter>DEBUGLEVEL</parameter></term>
 	<listitem>
 	  <para>
-	    Default is ERR (0).  Corresponds to <option>-d</option> or
+	    Default is NOTICE (2).  Corresponds to <option>-d</option> or
 	    <option>--debug</option>.
 	  </para>
 	</listitem>
diff --git a/server/ctdb_lock.c b/server/ctdb_lock.c
index 8638cd7..9833a75 100644
--- a/server/ctdb_lock.c
+++ b/server/ctdb_lock.c
@@ -486,6 +486,8 @@ static void ctdb_lock_timeout_handler(struct tevent_context *ev,
 	struct lock_context *lock_ctx;
 	struct ctdb_context *ctdb;
 	pid_t pid;
+	double elapsed_time;
+	int new_timer;
 
 	lock_ctx = talloc_get_type_abort(private_data, struct lock_context);
 	ctdb = lock_ctx->ctdb;
@@ -495,16 +497,17 @@ static void ctdb_lock_timeout_handler(struct tevent_context *ev,
 		lock_ctx->ttimer = NULL;
 		return;
 	}
+
+	elapsed_time = timeval_elapsed(&lock_ctx->start_time);
 	if (lock_ctx->ctdb_db) {
 		DEBUG(DEBUG_WARNING,
 		      ("Unable to get %s lock on database %s for %.0lf seconds\n",
 		       (lock_ctx->type == LOCK_RECORD ? "RECORD" : "DB"),
-		       lock_ctx->ctdb_db->db_name,
-		       timeval_elapsed(&lock_ctx->start_time)));
+		       lock_ctx->ctdb_db->db_name, elapsed_time));
 	} else {
 		DEBUG(DEBUG_WARNING,
 		      ("Unable to get ALLDB locks for %.0lf seconds\n",
-		       timeval_elapsed(&lock_ctx->start_time)));
+		       elapsed_time));
 	}
 
 	/* Fire a child process to find the blocking process. */
@@ -529,11 +532,20 @@ static void ctdb_lock_timeout_handler(struct tevent_context *ev,
 		       " Unable to setup lock debugging - no memory?\n"));
 	}
 
+	/* Back-off logging if lock is not obtained for a long time */
+	if (elapsed_time < 100.0) {
+		new_timer = 10;
+	} else if (elapsed_time < 1000.0) {
+		new_timer = 100;
+	} else {
+		new_timer = 1000;
+	}
+
 	/* reset the timeout timer */
 	// talloc_free(lock_ctx->ttimer);
 	lock_ctx->ttimer = tevent_add_timer(ctdb->ev,
 					    lock_ctx,
-					    timeval_current_ofs(10, 0),
+					    timeval_current_ofs(new_timer, 0),
 					    ctdb_lock_timeout_handler,
 					    (void *)lock_ctx);
 }
diff --git a/tests/INSTALL b/tests/INSTALL
index 5581989..7d83125 100755
--- a/tests/INSTALL
+++ b/tests/INSTALL
@@ -71,7 +71,7 @@ for d in $data_subdirs ; do
 done
 # Some of the unit tests have relative symlinks back to in-tree bits
 # and pieces.  These links will be broken!
-for i in "events.d" "functions" "nfs-rpc-checks.d" ; do
+for i in "events.d" "functions" "nfs-rpc-checks.d" "statd-callout" ; do
     ln -sf "${etcdir}/ctdb/${i}" "${ctdb_datadir}/eventscripts/etc-ctdb/${i}"
 done
 # test_wrap needs to set TEST_BIN_DIR
diff --git a/tests/eventscripts/etc-ctdb/statd-callout b/tests/eventscripts/etc-ctdb/statd-callout
deleted file mode 100755
index 51779bd..0000000
--- a/tests/eventscripts/etc-ctdb/statd-callout
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-# For now, always succeed.
-
-exit 0
diff --git a/tests/eventscripts/etc-ctdb/statd-callout b/tests/eventscripts/etc-ctdb/statd-callout
new file mode 120000
index 0000000..dbd3c98
--- /dev/null
+++ b/tests/eventscripts/etc-ctdb/statd-callout
@@ -0,0 +1 @@
+../../../config/statd-callout
\ No newline at end of file
diff --git a/tests/eventscripts/scripts/local.sh b/tests/eventscripts/scripts/local.sh
index e394bef..aa7d376 100644
--- a/tests/eventscripts/scripts/local.sh
+++ b/tests/eventscripts/scripts/local.sh
@@ -9,6 +9,10 @@ EVENTSCRIPTS_PATH=""
 
 if [ -d "${TEST_SUBDIR}/stubs" ] ; then
     EVENTSCRIPTS_PATH="${TEST_SUBDIR}/stubs"
+    case "$EVENTSCRIPTS_PATH" in
+	/*) : ;;
+	*) EVENTSCRIPTS_PATH="${PWD}/${EVENTSCRIPTS_PATH}" ;;
+    esac
 fi
 
 export EVENTSCRIPTS_PATH
@@ -276,6 +280,33 @@ ctdb_set_output ()
     eventscripts_test_add_cleanup "rm -f $_out $_rc"
 }
 
+# For now this creates the same public addresses each time.  However,
+# it could be made more flexible.
+setup_public_addresses ()
+{
+    if [ -f "$CTDB_PUBLIC_ADDRESSES" -a \
+	    "${CTDB_PUBLIC_ADDRESSES%/*}" = "$EVENTSCRIPTS_TESTS_VAR_DIR" ] ; then
+	rm "$CTDB_PUBLIC_ADDRESSES"
+    fi
+
+    export CTDB_PUBLIC_ADDRESSES=$(mktemp \
+				       --tmpdir="$EVENTSCRIPTS_TESTS_VAR_DIR" \
+				       "public-addresses-XXXXXXXX")
+
+    echo "Setting up CTDB_PUBLIC_ADDRESSES=${CTDB_PUBLIC_ADDRESSES}"
+    cat >"$CTDB_PUBLIC_ADDRESSES" <<EOF
+10.0.0.1/24 dev123
+10.0.0.2/24 dev123
+10.0.0.3/24 dev123
+10.0.0.4/24 dev123
+10.0.0.5/24 dev123
+10.0.0.6/24 dev123
+10.0.1.1/24 dev456
+10.0.1.2/24 dev456
+10.0.1.3/24 dev456
+EOF
+}
+
 setup_ctdb ()
 {
     setup_generic
@@ -286,17 +317,7 @@ setup_ctdb ()
     export FAKE_CTDB_PNN="${2:-0}"
     echo "Setting up CTDB with PNN ${FAKE_CTDB_PNN}"
 
-    export CTDB_PUBLIC_ADDRESSES="${CTDB_BASE}/public_addresses"
-    if [ -n "$3" ] ; then
-	echo "Setting up CTDB_PUBLIC_ADDRESSES: $3"
-	CTDB_PUBLIC_ADDRESSES=$(mktemp)
-	for _i in $3 ; do
-	    _ip="${_i%@*}"
-	    _ifaces="${_i#*@}"
-	    echo "${_ip} ${_ifaces}" >>"$CTDB_PUBLIC_ADDRESSES"
-	done
-	eventscripts_test_add_cleanup "rm -f $CTDB_PUBLIC_ADDRESSES"
-    fi
+    setup_public_addresses
 
     export FAKE_CTDB_STATE="$EVENTSCRIPTS_TESTS_VAR_DIR/fake-ctdb"
 
@@ -516,7 +537,66 @@ default via $_gw dev $_dev "
 EOF
 
 	simple_test_command dump_routes
-    }
+    } || test_fail
+}
+
+######################################################################
+
+ctdb_catdb_format_pairs ()
+{
+    _count=0
+
+    while read _k _v ; do
+	_kn=$(echo -n "$_k" | wc -c)
+	_vn=$(echo -n "$_v" | wc -c)
+	cat <<EOF
+key(${_kn}) = "${_k}"
+dmaster: 0
+rsn: 1
+data(${_vn}) = "${_v}"


-- 
CTDB repository


More information about the samba-cvs mailing list