[SCM] Samba Shared Repository - branch master updated

Amitay Isaacs amitay at samba.org
Fri May 28 07:35:01 UTC 2021


The branch, master has been updated
       via  f7cf8132b00 ctdb-tests: Add debug_locks.sh tests for mutexes
       via  99c3b49260f ctdb-scripts: Add lock debugging for tdb mutex locks
       via  cb55b68b3e6 ctdb-utils: Add tdb_mutex_check utility
       via  dd5972b6991 ctdb-scripts: Simplify logic in debug_via_proc_locks()
       via  e62ae53ef6d ctdb-scripts: Update debug_locks.sh to handle arguments
       via  1dfff9751b1 ctdb-scripts: Move current lock debugging to a function
       via  d07875330a6 ctdb-locking: Pass additional arguments to debug locks script
       via  2c7dbb043f3 ctdb-tests: Add debug_locks.sh testing
       via  a3e7fd9c61b ctdb-tests: Fix nonsense arguments to ps stub
       via  ffb56c9143d ctdb-scripts: Avoid direct /proc access
       via  55d4b3438f2 ctdb-scripts: Factor out function dump_stacks()
      from  f753e2f7acf s3:lib: Remove util_cmdline

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


- Log -----------------------------------------------------------------
commit f7cf8132b007aadc861efcb26060c075c45978b5
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jan 6 21:38:31 2021 +1100

    ctdb-tests: Add debug_locks.sh tests for mutexes
    
    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 May 28 07:34:23 UTC 2021 on sn-devel-184

commit 99c3b49260ffcb582122017bc545502a88b3cd31
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Feb 12 19:13:48 2021 +1100

    ctdb-scripts: Add lock debugging for tdb mutex locks
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit cb55b68b3e63b438f4695e362ffa8faae47d0aee
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Feb 12 19:13:11 2021 +1100

    ctdb-utils: Add tdb_mutex_check utility
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit dd5972b69916fa08b114193d644faf3ae58c550b
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Jan 4 13:35:11 2021 +1100

    ctdb-scripts: Simplify logic in debug_via_proc_locks()
    
    The path of the TDB is known, so calculate the file ID (device number
    + inode number) from it and use this to directly filter /proc/locks to
    find processes holding locks.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit e62ae53ef6d04016e3a3453380c9add3ce888e3c
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Feb 12 19:08:37 2021 +1100

    ctdb-scripts: Update debug_locks.sh to handle arguments
    
    Don't use the  arguments yet.  They will be used in a simplified
    version of the code.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 1dfff9751b1ef96d0ec5e4a72f7e687702c35a78
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Feb 12 19:07:55 2021 +1100

    ctdb-scripts: Move current lock debugging to a function
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit d07875330a6dbf44c1d65c029af80b53e5836d2d
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Nov 24 13:25:04 2020 +1100

    ctdb-locking: Pass additional arguments to debug locks script
    
    1. PID of lock helper waiting for lock
    2. Scope of lock: "record" or "db"
    3. Path to database that lock helper is trying to lock
    4. Whether the database uses mutexes: "mutex" or "fcntl"
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 2c7dbb043f3b7c0fa31791a033f21e249593d9f7
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jan 6 21:38:31 2021 +1100

    ctdb-tests: Add debug_locks.sh testing
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit a3e7fd9c61bf37de3d6952fa8c7134a4df0b9c6c
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Feb 12 18:57:58 2021 +1100

    ctdb-tests: Fix nonsense arguments to ps stub
    
    These were fine (though still lazy) when these tests were the only
    user of this stub.  However, the ps stub is about to be enhanced, so
    fix these uses of it to represent the intended usage.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit ffb56c9143d1d4b9a2dfaa8300be6ce5d6881ab1
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Jan 4 11:54:38 2021 +1100

    ctdb-scripts: Avoid direct /proc access
    
    The main reason for this is to facilitate testing.
    
    Avoid some /proc accesses entirely by using ps(1) (which can be
    replaced by a stub when testing) because this script might as well be
    more portable in case anyone wants to add lock debugging for a
    non-Linux platform.  While the "state" format specification isn't
    POSIX-compliant, it works on both Linux and FreeBSD so it is a
    reasonable improvement.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 55d4b3438f2c44a12b4c513ef26e2d1c4fa9f5b4
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Feb 12 19:14:12 2021 +1100

    ctdb-scripts: Factor out function dump_stacks()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

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

Summary of changes:
 ctdb/config/debug_locks.sh                         | 233 ++++++++++++++-----
 ctdb/packaging/RPM/ctdb.spec.in                    |   1 +
 ctdb/server/ctdb_lock.c                            |  61 ++++-
 .../UNIT/eventscripts/05.system.monitor.015.sh     |   2 +-
 .../UNIT/eventscripts/05.system.monitor.017.sh     |   2 +-
 .../UNIT/eventscripts/05.system.monitor.018.sh     |   4 +-
 ctdb/tests/UNIT/eventscripts/debug_locks.sh.001.sh |   9 +
 ctdb/tests/UNIT/eventscripts/debug_locks.sh.002.sh |   9 +
 ctdb/tests/UNIT/eventscripts/debug_locks.sh.003.sh |   9 +
 ctdb/tests/UNIT/eventscripts/debug_locks.sh.004.sh |   9 +
 ctdb/tests/UNIT/eventscripts/debug_locks.sh.005.sh |   9 +
 ctdb/tests/UNIT/eventscripts/debug_locks.sh.006.sh |   9 +
 ctdb/tests/UNIT/eventscripts/debug_locks.sh.007.sh |   9 +
 ctdb/tests/UNIT/eventscripts/debug_locks.sh.008.sh |   9 +
 ctdb/tests/UNIT/eventscripts/debug_locks.sh.021.sh |   9 +
 ctdb/tests/UNIT/eventscripts/debug_locks.sh.022.sh |   9 +
 ctdb/tests/UNIT/eventscripts/debug_locks.sh.023.sh |   9 +
 ctdb/tests/UNIT/eventscripts/debug_locks.sh.024.sh |   9 +
 ctdb/tests/UNIT/eventscripts/debug_locks.sh.025.sh |   9 +
 ctdb/tests/UNIT/eventscripts/debug_locks.sh.026.sh |   9 +
 ctdb/tests/UNIT/eventscripts/debug_locks.sh.027.sh |   9 +
 ctdb/tests/UNIT/eventscripts/debug_locks.sh.028.sh |   9 +
 ctdb/tests/UNIT/eventscripts/etc-ctdb/rc.local     |   8 +
 .../tests/UNIT/eventscripts/scripts/debug_locks.sh | 255 +++++++++++++++++++++
 ctdb/tests/UNIT/eventscripts/scripts/local.sh      |   8 +-
 ctdb/tests/UNIT/eventscripts/stubs/gstack          |  19 ++
 ctdb/tests/UNIT/eventscripts/stubs/ps              |  36 +++
 ctdb/tests/UNIT/eventscripts/stubs/stat            |  71 ++++++
 ctdb/tests/UNIT/eventscripts/stubs/tdb_mutex_check |  10 +
 ctdb/utils/tdb/tdb_mutex_check.c                   | 148 ++++++++++++
 ctdb/wscript                                       |  17 ++
 31 files changed, 954 insertions(+), 65 deletions(-)
 create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.001.sh
 create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.002.sh
 create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.003.sh
 create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.004.sh
 create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.005.sh
 create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.006.sh
 create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.007.sh
 create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.008.sh
 create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.021.sh
 create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.022.sh
 create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.023.sh
 create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.024.sh
 create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.025.sh
 create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.026.sh
 create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.027.sh
 create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.028.sh
 create mode 100644 ctdb/tests/UNIT/eventscripts/scripts/debug_locks.sh
 create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/gstack
 create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/stat
 create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/tdb_mutex_check
 create mode 100644 ctdb/utils/tdb/tdb_mutex_check.c


Changeset truncated at 500 lines:

diff --git a/ctdb/config/debug_locks.sh b/ctdb/config/debug_locks.sh
index 1f89cb7353c..b2e20250f5a 100755
--- a/ctdb/config/debug_locks.sh
+++ b/ctdb/config/debug_locks.sh
@@ -1,17 +1,42 @@
 #!/bin/sh
 
-# This script parses /proc/locks and finds the processes that are holding
-# locks on CTDB databases.  For all those processes the script dumps a
-# stack trace.
+# This script attempts to find processes holding locks on a particular
+# CTDB database and dumps a stack trace for each such processe.
 #
-# This script can be used only if Samba is configured to use fcntl locks
-# rather than mutex locks.
+# There are 2 cases:
+#
+# * Samba is configured to use fcntl locks
+#
+#   In this case /proc/locks is parsed to find potential lock holders
+#
+# * Samba is configured to use POSIX robust mutexes
+#
+#   In this case the helper program tdb_mutex_check is used to find
+#   potential lock holders.
+#
+#   This helper program uses a private glibc struct field, so is
+#   neither portable nor supported.  If this field is not available
+#   then the helper is not built.  Unexpected changes in internal
+#   glibc structures may cause unexpected results, including crashes.
+#   Bug reports for this helper program are not accepted without an
+#   accompanying patch.
 
 [ -n "$CTDB_BASE" ] || \
     CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; echo "$PWD")
 
 . "${CTDB_BASE}/functions"
 
+if [ $# -ne 4 ] ; then
+	die "usage: $0 <pid> { DB | RECORD } <tdb_path> { FCNTL | MUTEX }"
+fi
+
+lock_helper_pid="$1"
+# lock_scope is unused for now
+# shellcheck disable=SC2034
+lock_scope="$2"
+tdb_path="$3"
+lock_type="$4"
+
 # type is at least mentioned in POSIX and more is portable than which(1)
 # shellcheck disable=SC2039
 if ! type gstack >/dev/null 2>&1 ; then
@@ -28,50 +53,13 @@ fi
 # Load/cache database options from configuration file
 ctdb_get_db_options
 
-(
-    flock -n 9 || exit 1
-
-    echo "===== Start of debug locks PID=$$ ====="
-
-    # Create sed expression to convert inodes to names.
-    # Filenames don't contain dashes and we want basenames
-    # shellcheck disable=SC2035
-    sed_cmd=$(cd "$CTDB_DBDIR" &&
-		  stat -c "s#[0-9a-f]*:[0-9a-f]*:%i #%n #" *.tdb.* 2>/dev/null ;
-	      cd "$CTDB_DBDIR_PERSISTENT" &&
-		  stat -c "s#[0-9a-f]*:[0-9a-f]*:%i #%n #" *.tdb.* 2>/dev/null)
-
-    # Parse /proc/locks and extract following information
-    #    pid process_name tdb_name offsets [W]
-    out=$( grep -F "POSIX  ADVISORY  WRITE" /proc/locks |
-    awk '{ if($2 == "->") { print $6, $7, $8, $9, "W" } else { print $5, $6, $7, $8 } }' |
-    while read pid rest ; do
-	pname=$(readlink "/proc/${pid}/exe")
-	echo "$pid $pname $rest"
-    done | sed -e "$sed_cmd" | grep '\.tdb' )
-
-    if [ -n "$out" ]; then
-	# Log information about locks
-	echo "$out"
-
-	# Find processes that are waiting for locks
-	dbs=$(echo "$out" | grep "W$" | awk '{print $3}')
-	all_pids=""
-	for db in $dbs ; do
-	    pids=$(echo "$out" | grep -v "W$" | grep "$db" | grep -v ctdbd | awk '{print $1}')
-	    all_pids="$all_pids $pids"
-	done
-	# Use word splitting to squash whitespace
-	# shellcheck disable=SC2086
-	pids=$(echo $all_pids | tr ' ' '\n' | sort -u)
-
-	# For each process waiting, log stack trace
-	for pid in $pids ; do
-	    echo "----- Stack trace for PID=$pid -----"
-	    # x is intentionally ignored
-	    # shellcheck disable=SC2034
-	    read x x state x <"/proc/${pid}/stat"
-	    if [ "$state" = "D" ] ; then
+dump_stack ()
+{
+	_pid="$1"
+
+	echo "----- Stack trace for PID=${_pid} -----"
+	_state=$(ps -p "$_pid" -o state= | cut -c 1)
+	if [ "$_state" = "D" ] ; then
 		# Don't run gstack on a process in D state since
 		# gstack will hang until the process exits D state.
 		# Although it is possible for a process to transition
@@ -82,14 +70,149 @@ ctdb_get_db_options
 		# deadlock... but it will probably give us someone to
 		# blame!
 		echo "----- Process in D state, printing kernel stack only"
-		cat "/proc/${pid}/stack"
-	    else
-		gstack "$pid"
-	    fi
+		get_proc "${_pid}/stack"
+	else
+		gstack "$_pid"
+	fi
+}
+
+dump_stacks ()
+{
+	_pids="$1"
+
+	# Use word splitting to squash whitespace
+	# shellcheck disable=SC2086
+	_pids=$(echo $_pids | tr ' ' '\n' | sort -u)
+
+	for _pid in $_pids; do
+		dump_stack "$_pid"
 	done
-    fi
+}
+
+get_tdb_file_id ()
+{
+	if ! _device_inode=$(stat -c "%d:%i" "$tdb_path" 2>/dev/null) ; then
+		die "Unable to stat \"${tdb_path}\""
+	fi
+	_device="${_device_inode%%:*}"
+	_device_major=$((_device >> 8))
+	_device_minor=$((_device & 0xff))
+	_inode="${_device_inode#*:}"
+	printf '%02x:%02x:%u\n' "$_device_major" "$_device_minor" "$_inode"
+}
+
+debug_via_proc_locks ()
+{
+	# Get file ID to match relevant column in /proc/locks
+	_file_id=$(get_tdb_file_id)
+
+	# Log information from /proc/locks about the waiting process
+	_tdb=$(basename "$tdb_path")
+	_comm=$(ps -p "$lock_helper_pid" -o comm=)
+	_out=$(get_proc "locks" |
+	       awk -v pid="$lock_helper_pid" \
+		   -v file_id="$_file_id" \
+		   -v file="$_tdb" \
+		   -v comm="$_comm" \
+		   '$2 == "->" &&
+		    $3 == "POSIX" &&
+		    $4 == "ADVISORY" &&
+		    $5 == "WRITE" &&
+		    $6 == pid &&
+		    $7 == file_id { print $6, comm, file, $8, $9 }')
+	if [ -n "$_out" ] ; then
+		echo "Waiter:"
+		echo "$_out"
+	fi
+
+	# Parse /proc/locks and find process holding locks on $tdb_path
+	# extract following information
+	#    pid process_name tdb_name offsets
+	_out=$(get_proc "locks" |
+	       awk -v pid="$lock_helper_pid" \
+		   -v file_id="$_file_id" \
+		   -v file="$_tdb" \
+		   '$2 == "POSIX" &&
+		    $3 == "ADVISORY" &&
+		    $4 == "WRITE" &&
+		    $5 != pid &&
+		    $6 == file_id { print $5, file, $7, $8 }' |
+	       while read -r _pid _rest ; do
+		       _pname=$(ps -p "$_pid" -o comm=)
+		       echo "$_pid $_pname $_rest"
+	       done)
+
+	if [ -z "$_out" ]; then
+		return
+	fi
+
+	# Log information about locks
+	echo "Lock holders:"
+	echo "$_out"
+
+	_pids=$(echo "$_out" | awk '{ print $1 }')
+
+	lock_holder_pids="${lock_holder_pids:+${lock_holder_pids} }${_pids}"
+}
+
+debug_via_tdb_mutex ()
+{
+	_helper="${CTDB_HELPER_BINDIR}/tdb_mutex_check"
+	if [ ! -x "$_helper" ] ; then
+		# Mutex helper not available - not supported?
+		# Avoid not found error...
+		return
+	fi
+
+	# Helper should always succeed
+	if ! _t=$("$_helper" "$tdb_path") ; then
+		return
+	fi
+
+	_out=$(echo "$_t" | sed -n -e 's#^\[\(.*\)\] pid=\(.*\)#\2 \1#p')
+
+	if [ -z "$_out" ]; then
+		if [ -n "$_t" ] ; then
+			echo "$_t" | grep -F 'trylock failed'
+		fi
+		return
+	fi
+
+	# Get process names, append $tdb_path
+	_out=$(echo "$_out" |
+	       while read -r _pid _rest ; do
+		       _pname=$(ps -p "$_pid" -o comm=)
+		       _tdb=$(basename "$tdb_path")
+		       echo "${_pid} ${_pname} ${_tdb} ${_rest}"
+	       done)
+
+	# Log information about locks
+	echo "Lock holders:"
+	echo "$_out"
+
+	# Get PIDs of processes that are holding locks
+	_pids=$(echo "$_out" |
+		awk -v pid="$lock_helper_pid" '$1 != pid {print $1}')
+
+	lock_holder_pids="${lock_holder_pids:+${lock_holder_pids} }${_pids}"
+}
+
+(
+	flock -n 9 || exit 1
+
+	echo "===== Start of debug locks PID=$$ ====="
+
+	lock_holder_pids=""
+
+	debug_via_proc_locks
+
+	if [ "$lock_type" = "MUTEX" ] ; then
+		debug_via_tdb_mutex
+	fi
+
+	dump_stacks "$lock_holder_pids"
 
-    echo "===== End of debug locks PID=$$ ====="
+	echo "===== End of debug locks PID=$$ ====="
 )9>"${CTDB_SCRIPT_VARDIR}/debug_locks.lock" | script_log "ctdbd-lock"
 
 exit 0
diff --git a/ctdb/packaging/RPM/ctdb.spec.in b/ctdb/packaging/RPM/ctdb.spec.in
index efece159bdc..80eb2945e41 100644
--- a/ctdb/packaging/RPM/ctdb.spec.in
+++ b/ctdb/packaging/RPM/ctdb.spec.in
@@ -223,6 +223,7 @@ fi
 %dir %{_libexecdir}/ctdb
 %{_libexecdir}/ctdb/*
 %dir %{_libdir}/ctdb
+%{_libexecdir}/tdb_mutex_check
 %{_libdir}/ctdb/lib*
 %dir %{_datadir}/ctdb/events
 %{_datadir}/ctdb/events/*
diff --git a/ctdb/server/ctdb_lock.c b/ctdb/server/ctdb_lock.c
index 478447d76f8..063ebfa07cf 100644
--- a/ctdb/server/ctdb_lock.c
+++ b/ctdb/server/ctdb_lock.c
@@ -496,6 +496,50 @@ fail:
 
 }
 
+static const char **debug_locks_args(TALLOC_CTX *mem_ctx, struct lock_context *lock_ctx)
+{
+	const char **args = NULL;
+	int tdb_flags;
+	int nargs, i;
+
+	/* Program, lock helper PID, db|record, tdb path, fcntl|mutex, NULL */
+	nargs = 6;
+
+	args = talloc_array(mem_ctx, const char *, nargs);
+	if (args == NULL) {
+		return NULL;
+	}
+
+	args[0] = talloc_strdup(args, "debug_locks");
+	args[1] = talloc_asprintf(args, "%d", lock_ctx->child);
+
+	if (lock_ctx->type == LOCK_RECORD) {
+		args[2] = talloc_strdup(args, "RECORD");
+	} else {
+		args[2] = talloc_strdup(args, "DB");
+	}
+
+	args[3] = talloc_strdup(args, lock_ctx->ctdb_db->db_path);
+
+	tdb_flags = tdb_get_flags(lock_ctx->ctdb_db->ltdb->tdb);
+	if (tdb_flags & TDB_MUTEX_LOCKING) {
+		args[4] = talloc_strdup(args, "MUTEX");
+	} else {
+		args[4] = talloc_strdup(args, "FCNTL");
+	}
+
+	args[5] = NULL;
+
+	for (i=0; i<nargs-1; i++) {
+		if (args[i] == NULL) {
+			talloc_free(args);
+			return NULL;
+		}
+	}
+
+	return args;
+}
+
 /*
  * Callback routine when required locks are not obtained within timeout
  * Called from parent context
@@ -512,6 +556,7 @@ static void ctdb_lock_timeout_handler(struct tevent_context *ev,
 	double elapsed_time;
 	bool skip;
 	char *keystr;
+	const char **args;
 
 	lock_ctx = talloc_get_type_abort(private_data, struct lock_context);
 	ctdb = lock_ctx->ctdb;
@@ -554,12 +599,18 @@ lock_debug:
 			    debug_locks, sizeof(debug_locks),
 			    "CTDB_DEBUG_LOCKS",
 			    getenv("CTDB_BASE"), "debug_locks.sh")) {
-		pid = vfork();
-		if (pid == 0) {
-			execl(debug_locks, debug_locks, NULL);
-			_exit(0);
+		args = debug_locks_args(lock_ctx, lock_ctx);
+		if (args != NULL) {
+			pid = vfork();
+			if (pid == 0) {
+				execvp(debug_locks, discard_const(args));
+				_exit(0);
+			}
+			talloc_free(args);
+			ctdb_track_child(ctdb, pid);
+		} else {
+			D_WARNING("No memory for debug locks args\n");
 		}
-		ctdb_track_child(ctdb, pid);
 	} else {
 		DEBUG(DEBUG_WARNING,
 		      (__location__
diff --git a/ctdb/tests/UNIT/eventscripts/05.system.monitor.015.sh b/ctdb/tests/UNIT/eventscripts/05.system.monitor.015.sh
index 0091c429ac1..76b73a34284 100755
--- a/ctdb/tests/UNIT/eventscripts/05.system.monitor.015.sh
+++ b/ctdb/tests/UNIT/eventscripts/05.system.monitor.015.sh
@@ -14,7 +14,7 @@ set_mem_usage 90 90
 required_result 1 <<EOF
 ERROR: System memory utilization 90% >= threshold 85%
 $FAKE_PROC_MEMINFO
-$(ps foobar)
+$(ps auxfww)
 EOF
 
 simple_test
diff --git a/ctdb/tests/UNIT/eventscripts/05.system.monitor.017.sh b/ctdb/tests/UNIT/eventscripts/05.system.monitor.017.sh
index 8eef4afc85d..b2e50292a03 100755
--- a/ctdb/tests/UNIT/eventscripts/05.system.monitor.017.sh
+++ b/ctdb/tests/UNIT/eventscripts/05.system.monitor.017.sh
@@ -14,7 +14,7 @@ set_mem_usage 87 87
 required_result 1 <<EOF
 ERROR: System memory utilization 87% >= threshold 80%
 $FAKE_PROC_MEMINFO
-$(ps foobar)
+$(ps auxfww)
 EOF
 
 simple_test
diff --git a/ctdb/tests/UNIT/eventscripts/05.system.monitor.018.sh b/ctdb/tests/UNIT/eventscripts/05.system.monitor.018.sh
index cd9305f8826..427adc61eed 100755
--- a/ctdb/tests/UNIT/eventscripts/05.system.monitor.018.sh
+++ b/ctdb/tests/UNIT/eventscripts/05.system.monitor.018.sh
@@ -41,7 +41,7 @@ set_mem_usage 80 80
 required_result 1 <<EOF
 ERROR: System memory utilization 80% >= threshold 80%
 $FAKE_PROC_MEMINFO
-$(ps foobar)
+$(ps auxfww)
 EOF
 simple_test
 
@@ -72,7 +72,7 @@ set_mem_usage 81 81
 required_result 1 <<EOF
 ERROR: System memory utilization 81% >= threshold 80%
 $FAKE_PROC_MEMINFO
-$(ps foobar)
+$(ps auxfww)
 EOF
 simple_test
 
diff --git a/ctdb/tests/UNIT/eventscripts/debug_locks.sh.001.sh b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.001.sh
new file mode 100755
index 00000000000..8f102001a97
--- /dev/null
+++ b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.001.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "DB S+ DB"
+
+setup
+
+do_test "DB" "S+" "DB"
diff --git a/ctdb/tests/UNIT/eventscripts/debug_locks.sh.002.sh b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.002.sh
new file mode 100755
index 00000000000..31ae3dff1f6
--- /dev/null
+++ b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.002.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "DB D. DB"
+
+setup
+
+do_test "DB" "D." "DB"
diff --git a/ctdb/tests/UNIT/eventscripts/debug_locks.sh.003.sh b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.003.sh
new file mode 100755
index 00000000000..89ab2f1bb58
--- /dev/null
+++ b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.003.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "RECORD S+ DB"
+
+setup
+
+do_test "RECORD" "S+" "DB"
diff --git a/ctdb/tests/UNIT/eventscripts/debug_locks.sh.004.sh b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.004.sh
new file mode 100755
index 00000000000..35500cbd04c
--- /dev/null
+++ b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.004.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "RECORD D. DB"
+
+setup
+
+do_test "RECORD" "D." "DB"
diff --git a/ctdb/tests/UNIT/eventscripts/debug_locks.sh.005.sh b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.005.sh
new file mode 100755
index 00000000000..10cbade46a5
--- /dev/null
+++ b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.005.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "DB S+ RECORD"
+
+setup
+
+do_test "DB" "S+" "RECORD"
diff --git a/ctdb/tests/UNIT/eventscripts/debug_locks.sh.006.sh b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.006.sh
new file mode 100755
index 00000000000..c4988b7e26d
--- /dev/null
+++ b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.006.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "DB D. RECORD"
+


-- 
Samba Shared Repository



More information about the samba-cvs mailing list