[SCM] CTDB repository - branch master updated - ctdb-1.0.87-42-g836b95f

Ronnie Sahlberg sahlberg at samba.org
Tue Aug 4 01:53:35 MDT 2009


The branch, master has been updated
       via  836b95f32724cf37e4f643f20653f78842613692 (commit)
       via  c513a31d755003d7af91529790b06ce0d226c90f (commit)
       via  875778fbbfd6b0f09fd2db76f7348ad6271350a3 (commit)
       via  a0ad69197b4771f3d5be23d78d0933d732405f08 (commit)
       via  afafab0ac6cac90c3f8614204b5b6df92e446728 (commit)
       via  64405bdbebb2ddf0ae980e958ede77df79139000 (commit)
      from  8f48e37c254e0852d4e2dea54b905ce5ef2b925d (commit)

http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 836b95f32724cf37e4f643f20653f78842613692
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jul 30 12:02:27 2009 +0200

    tests: fix the 52_ctdb_fetch.sh test.
    
    The parser for the output of the ctdb_fetch program
    did not match the output that ctdb_fetch generates.
    It seemed to rather come from the ctdb_bench test...
    
    This patch adapts the parser to correctly interpret
    the output of ctdb_fetch.
    
    Michael

commit c513a31d755003d7af91529790b06ce0d226c90f
Author: Michael Adam <obnox at samba.org>
Date:   Sun Jul 12 00:39:29 2009 +0200

    client: fix a debug message (misplaced newline).
    
    Michael

commit 875778fbbfd6b0f09fd2db76f7348ad6271350a3
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jul 15 10:03:03 2009 +0200

    client:ctdb_control_send: remove duplicate setting of the reqid header.
    
    Michael

commit a0ad69197b4771f3d5be23d78d0933d732405f08
Author: Michael Adam <obnox at samba.org>
Date:   Tue Jul 21 09:50:56 2009 +0200

    ctdbd: use ctdb_syslog_log() as debug_add function for syslog
    
    Michael

commit afafab0ac6cac90c3f8614204b5b6df92e446728
Author: Michael Adam <obnox at samba.org>
Date:   Tue Jul 21 09:48:10 2009 +0200

    ctdbd: set debug_add hook to be able to use dump_data in the daemon.
    
    Michael

commit 64405bdbebb2ddf0ae980e958ede77df79139000
Author: Michael Adam <obnox at samba.org>
Date:   Tue Jul 21 09:47:07 2009 +0200

    debug: add debug_add and dump_data functions
    
    Michael

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

Summary of changes:
 client/ctdb_client.c          |    3 +-
 lib/util/debug.c              |   79 ++++++++++++++++++++++++++++++++++++++++-
 lib/util/debug.h              |    2 +
 server/ctdb_logging.c         |   22 +++++++++++
 tests/simple/52_ctdb_fetch.sh |   45 +++++------------------
 5 files changed, 112 insertions(+), 39 deletions(-)


Changeset truncated at 500 lines:

diff --git a/client/ctdb_client.c b/client/ctdb_client.c
index f6dbc73..2e7a093 100644
--- a/client/ctdb_client.c
+++ b/client/ctdb_client.c
@@ -815,7 +815,6 @@ struct ctdb_client_control_state *ctdb_control_send(struct ctdb_context *ctdb,
 	CTDB_NO_MEMORY_NULL(ctdb, c);
 	c->hdr.reqid        = state->reqid;
 	c->hdr.destnode     = destnode;
-	c->hdr.reqid        = state->reqid;
 	c->opcode           = opcode;
 	c->client_id        = 0;
 	c->flags            = flags;
@@ -2802,7 +2801,7 @@ static void async_callback(struct ctdb_client_control_state *state)
 	*/
 	if (state->state != CTDB_CONTROL_DONE) {
 		if ( !data->dont_log_errors) {
-			DEBUG(DEBUG_ERR,("Async operation failed with state %d\n opcode:%u", state->state, data->opcode));
+			DEBUG(DEBUG_ERR,("Async operation failed with state %d, opcode:%u\n", state->state, data->opcode));
 		}
 		data->fail_count++;
 		if (data->fail_callback) {
diff --git a/lib/util/debug.c b/lib/util/debug.c
index 2390f4c..63ca03b 100644
--- a/lib/util/debug.c
+++ b/lib/util/debug.c
@@ -20,7 +20,7 @@
 #include "includes.h"
 #include "system/time.h"
 #include <unistd.h>
-
+#include <ctype.h>
 
 static void _do_debug_v(const char *format, va_list ap)
 {
@@ -59,3 +59,80 @@ void do_debug(const char *format, ...)
 	va_end(ap);
 }
 
+
+static void _do_debug_add_v(const char *format, va_list ap)
+{
+	char *s = NULL;
+	int ret;
+
+	ret = vasprintf(&s, format, ap);
+	if (ret == -1) {
+		fprintf(stderr, "vasprintf failed in _do_debug_add_v, cannot print debug message.\n");
+		fflush(stderr);
+		return;
+	}
+
+	fprintf(stderr, "%s", s);
+	fflush(stderr);
+	free(s);
+}
+
+/* default logging function */
+void (*do_debug_add_v)(const char *, va_list ap) = _do_debug_add_v;
+
+void do_debug_add(const char *format, ...)
+{
+	va_list ap;
+
+	va_start(ap, format);
+	do_debug_add_v(format, ap);
+	va_end(ap);
+}
+
+#define DEBUGLVL(lvl) ((lvl) <= LogLevel)
+#define DEBUG(lvl, x) do { if ((lvl) <= LogLevel) { this_log_level = (lvl); do_debug x; }} while (0)
+#define DEBUGADD(lvl, x) do { if ((lvl) <= LogLevel) { this_log_level = (lvl); do_debug_add x; }} while (0)
+
+static void print_asc(int level, const uint8_t *buf, size_t len)
+{
+	int i;
+	for (i=0;i<len;i++) {
+		DEBUGADD(level,("%c", isprint(buf[i])?buf[i]:'.'));
+	}
+}
+
+void dump_data(int level, const uint8_t *buf, size_t len)
+{
+	int i=0;
+
+	if (len<=0) return;
+
+	if (!DEBUGLVL(level)) return;
+
+	DEBUG(level, (__location__ " dump data of size %i:\n", (int)len));
+	DEBUGADD(level,("[%03X] ",i));
+	for (i=0;i<len;) {
+		DEBUGADD(level,("%02X ",(int)buf[i]));
+		i++;
+		if (i%8 == 0) DEBUGADD(level,(" "));
+		if (i%16 == 0) {
+			print_asc(level,&buf[i-16],8); DEBUGADD(level,(" "));
+			print_asc(level,&buf[i-8],8); DEBUGADD(level,("\n"));
+			if (i<len) DEBUGADD(level,("[%03X] ",i));
+		}
+	}
+	if (i%16) {
+		int n;
+		n = 16 - (i%16);
+		DEBUGADD(level,(" "));
+		if (n>8) DEBUGADD(level,(" "));
+		while (n--) DEBUGADD(level,("   "));
+		n = MIN(8,i%16);
+		print_asc(level,&buf[i-(i%16)],n); DEBUGADD(level,( " " ));
+		n = (i%16) - n;
+		if (n>0) print_asc(level,&buf[i-n],n);
+		DEBUGADD(level,("\n"));
+	}
+	DEBUG(level, (__location__ " dump data of size %i finished\n", (int)len));
+}
+
diff --git a/lib/util/debug.h b/lib/util/debug.h
index ae21e71..a7d8978 100644
--- a/lib/util/debug.h
+++ b/lib/util/debug.h
@@ -18,4 +18,6 @@
 */
 
 void (*do_debug_v)(const char *, va_list ap);
+void (*do_debug_add_v)(const char *, va_list ap);
 void do_debug(const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
+void dump_data(int level, const uint8_t *buf1, size_t len);
diff --git a/server/ctdb_logging.c b/server/ctdb_logging.c
index bae27cf..930fa7b 100644
--- a/server/ctdb_logging.c
+++ b/server/ctdb_logging.c
@@ -109,6 +109,25 @@ static void ctdb_logfile_log(const char *format, va_list ap)
 	}
 }
 
+static void ctdb_logfile_log_add(const char *format, va_list ap)
+{
+	char *s = NULL;
+	int ret;
+
+	ret = vasprintf(&s, format, ap);
+	if (ret == -1) {
+		const char *errstr = "vasprintf failed\n";
+
+		write(log_state->fd, errstr, strlen(errstr));
+		return;
+	}
+
+	if (s) {
+		write(log_state->fd, s, strlen(s));
+		free(s);
+	}
+}
+
 /*
   choose the logfile location
 */
@@ -125,9 +144,11 @@ int ctdb_set_logfile(struct ctdb_context *ctdb, const char *logfile, bool use_sy
 
 	if (use_syslog) {
 		do_debug_v = ctdb_syslog_log;
+		do_debug_add_v = ctdb_syslog_log;
 		ctdb->log->use_syslog = true;
 	} else if (logfile == NULL || strcmp(logfile, "-") == 0) {
 		do_debug_v = ctdb_logfile_log;
+		do_debug_add_v = ctdb_logfile_log_add;
 		ctdb->log->fd = 1;
 		/* also catch stderr of subcommands to stdout */
 		ret = dup2(1, 2);
@@ -137,6 +158,7 @@ int ctdb_set_logfile(struct ctdb_context *ctdb, const char *logfile, bool use_sy
 		}
 	} else {
 		do_debug_v = ctdb_logfile_log;
+		do_debug_add_v = ctdb_logfile_log_add;
 
 		ctdb->log->fd = open(logfile, O_WRONLY|O_APPEND|O_CREAT, 0666);
 		if (ctdb->log->fd == -1) {
diff --git a/tests/simple/52_ctdb_fetch.sh b/tests/simple/52_ctdb_fetch.sh
index 3f0ecff..236b697 100755
--- a/tests/simple/52_ctdb_fetch.sh
+++ b/tests/simple/52_ctdb_fetch.sh
@@ -40,17 +40,20 @@ num_nodes=$(echo "$out" | wc -l)
 echo "Running ctdb_fetch on all $num_nodes nodes."
 try_command_on_node -v -pq all $CTDB_TEST_WRAPPER $VALGRIND ctdb_fetch -n $num_nodes
 
+pat='^(Fetch: [[:digit:]]+(\.[[:digit:]]+)? msgs/sec[[:space:]]?|msg_count=[[:digit:]]+ on node [[:digit:]]|Fetching final record|DATA:|Test data|Waiting for cluster[[:space:]]?|)+$'
+sanity_check_output 1 "$pat" "$out"
+
+# Filter out the performance figures:
+out_fetch=$(echo "$out" | egrep '^(Fetch: .*)+$')
+
 # Get the last line of output.
 while read line ; do
     prev=$line
-done <<<"$out"
-
-pat='^(Ring: [[:digit:]]+(\.[[:digit:]]+)? msgs/sec \(\+ve=[[:digit:]]+ -ve=[[:digit:]]+\)[[:space:]]?|Waiting for cluster[[:space:]]?)+$'
-sanity_check_output 1 "$pat" "$out"
+done <<<"$out_fetch"
 
 # $prev should look like this:
-#    Ring: 10670.93 msgs/sec (+ve=53391 -ve=53373)
-stuff="${prev##*Ring: }"
+#    Fetch: 10670.93 msgs/sec
+stuff="${prev##*Fetch: }"
 mps="${stuff% msgs/sec*}"
 
 if [ ${mps%.*} -ge 10 ] ; then
@@ -59,33 +62,3 @@ else
     echo "BAD: $mps msgs/sec < 10 msgs/sec"
     exit 1
 fi
-
-stuff="${stuff#*msgs/sec (+ve=}"
-positive="${stuff%% *}"
-
-if [ $positive -gt 0 ] ; then
-    echo "OK: +ive ($positive) > 0"
-else
-    echo "BAD: +ive ($positive) = 0"
-    exit 1
-fi
-
-stuff="${stuff#*-ve=}"
-negative="${stuff%)}"
-
-if [ $negative -gt 0 ] ; then
-    echo "OK: -ive ($negative) > 0"
-else
-    echo "BAD: -ive ($negative) = 0"
-    exit 1
-fi
-
-perc_diff=$(( ($positive - $negative) * 100 / $positive ))
-perc_diff=${perc_diff#-}
-
-if [ $perc_diff -le 1 ] ; then
-    echo "OK: percentage difference between +ive and -ive ($perc_diff%) <= 1%"
-else
-    echo "BAD: percentage difference between +ive and -ive ($perc_diff%) > 1%"
-    exit 1
-fi


-- 
CTDB repository


More information about the samba-cvs mailing list