[SCM] CTDB repository - branch master updated - ctdb-1.0.114-361-g2d478a3

Ronnie Sahlberg sahlberg at samba.org
Mon Oct 11 10:02:59 MDT 2010


The branch, master has been updated
       via  2d478a39ed8303b0371112d61630660d12b7db2c (commit)
       via  1919e949af4641ffe919123e44b02fb87c13ab9f (commit)
       via  15455a13863105a87d2cae9f06eed7435898c30b (commit)
       via  2a2a7a201c90462295544ca23c8a3e215f140622 (commit)
      from  500ade4e6a58ea786a665f6be7cf30f43c882570 (commit)

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


- Log -----------------------------------------------------------------
commit 2d478a39ed8303b0371112d61630660d12b7db2c
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Oct 12 02:49:11 2010 +1100

    move extracting the config from config.tdb for public addresses
    into its own function

commit 1919e949af4641ffe919123e44b02fb87c13ab9f
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Mon Oct 11 15:11:18 2010 +1100

    Update latency countes to show min/max and average

commit 15455a13863105a87d2cae9f06eed7435898c30b
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Mon Oct 11 07:09:18 2010 +1100

    Update the default hash size to be 100001 instead of 10000
    This can sometimes improve performance for environments where very many
    files are touched in rapid succession

commit 2a2a7a201c90462295544ca23c8a3e215f140622
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Mon Oct 11 07:05:41 2010 +1100

    Revert "change the hash function to use the much better Jenkins hash"
    
    This reverts commit f7e91ae905cd61249028e15f2cb509ea69f10b9e.
    
    This may require a change to the ctdb protocol, or a mechanism
    to negotiate/verify that we dont run with different hash fucntions
    across the cluster.
    
    Reverting the change until we decide how to solve this in the master
    version.

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

Summary of changes:
 common/ctdb_util.c       |    9 +++++-
 config/events.d/00.ctdb  |   34 ++++++++++++---------
 include/ctdb_private.h   |   39 +++++++++++++++++++-----
 include/ctdb_protocol.h  |   17 +++++++---
 server/ctdb_daemon.c     |   10 +++---
 server/ctdb_lockwait.c   |    2 +-
 server/ctdb_persistent.c |    2 +-
 server/ctdb_tunables.c   |    2 +-
 tools/ctdb.c             |   74 ++++++++++++++++++++++++++++++++++------------
 9 files changed, 133 insertions(+), 56 deletions(-)


Changeset truncated at 500 lines:

diff --git a/common/ctdb_util.c b/common/ctdb_util.c
index 749b9c2..4acfa3f 100644
--- a/common/ctdb_util.c
+++ b/common/ctdb_util.c
@@ -99,7 +99,14 @@ bool ctdb_same_address(struct ctdb_address *a1, struct ctdb_address *a2)
 */
 uint32_t ctdb_hash(const TDB_DATA *key)
 {
-	return tdb_jenkins_hash(discard_const(key));
+	uint32_t value;	/* Used to compute the hash value.  */
+	uint32_t i;	/* Used to cycle through random values. */
+
+	/* Set the initial value from the key size. */
+	for (value = 0x238F13AF * key->dsize, i=0; i < key->dsize; i++)
+		value = (value + (key->dptr[i] << (i*5 % 24)));
+
+	return (1103515243 * value + 12345);  
 }
 
 /*
diff --git a/config/events.d/00.ctdb b/config/events.d/00.ctdb
index 8ff6488..1389ae4 100755
--- a/config/events.d/00.ctdb
+++ b/config/events.d/00.ctdb
@@ -12,6 +12,24 @@
 . $CTDB_BASE/functions
 loadconfig
 
+update_config_from_tdb() {
+	# Pull optional ctdb configuration data out of config.tdb
+	PUBLICADDRESSESKEY='public-addresses:node#'`ctdb -t 1 xpnn|sed -e "s/.*://"`
+	rm -f $CTDB_VARDIR/state/public_addresses
+	ctdb pfetch config.tdb $PUBLICADDRESSESKEY $CTDB_VARDIR/state/public_addresses
+	[ "$?" = "0" ] && [ `stat --format="%s" /etc/ctdb/state/public_addresses` != "0" ] && [ ! -z "$CTDB_PUBLIC_ADDRESSES" ] && {
+		diff $CTDB_VARDIR/state/public_addresses $CTDB_PUBLIC_ADDRESSES >/dev/null 2>/dev/null
+		[ $? = "0" ] || {
+			echo CTDB public address configuration had been updated.
+			echo Extracting new configuration from database.
+			diff $CTDB_VARDIR/state/public_addresses $CTDB_PUBLIC_ADDRESSES
+			cp $CTDB_VARDIR/state/public_addresses $CTDB_PUBLIC_ADDRESSES
+			echo Restarting CTDB
+			service ctdb restart &
+		}
+	}
+}
+
 case "$1" in 
      init)
         # make sure we have a blank state directory for the scripts to work with
@@ -35,21 +53,7 @@ case "$1" in
 	;;
 
     startup)
-	# Pull optional ctdb configuration data out of config.tdb
-	PUBLICADDRESSESKEY='public-addresses:node#'`ctdb -t 1 xpnn|sed -e "s/.*://"`
-	rm -f $CTDB_VARDIR/state/public_addresses
-	ctdb pfetch config.tdb $PUBLICADDRESSESKEY $CTDB_VARDIR/state/public_addresses
-	[ "$?" = "0" ] && [ `stat --format="%s" /etc/ctdb/state/public_addresses` != "0" ] && [ ! -z "$CTDB_PUBLIC_ADDRESSES" ] && {
-		diff $CTDB_VARDIR/state/public_addresses $CTDB_PUBLIC_ADDRESSES >/dev/null 2>/dev/null
-		[ $? = "0" ] || {
-			echo CTDB public address configuration had been updated.
-			echo Extracting new configuration from database.
-			diff $CTDB_VARDIR/state/public_addresses $CTDB_PUBLIC_ADDRESSES
-			cp $CTDB_VARDIR/state/public_addresses $CTDB_PUBLIC_ADDRESSES
-			echo Restarting CTDB
-			service ctdb restart &
-		}
-	}
+	update_config_from_tdb &
 	;;
     monitor)
 	# We should never enter swap, so SwapTotal == SwapFree.
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index f018554..a99b4b0 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -304,10 +304,21 @@ struct ctdb_daemon_data {
 
 #define CTDB_UPDATE_RECLOCK_LATENCY(ctdb, name, counter, value) \
 	{										\
-		if (value > ctdb->statistics.counter)					\
-			ctdb->statistics.counter = value;				\
-		if (value > ctdb->statistics_current.counter)				\
-			ctdb->statistics_current.counter = value;			\
+		if (value > ctdb->statistics.counter.max)					\
+			ctdb->statistics.counter.max = value;				\
+		if (value > ctdb->statistics_current.counter.max)				\
+			ctdb->statistics_current.counter.max = value;			\
+											\
+		if (ctdb->statistics.counter.num == 0 || value < ctdb->statistics.counter.min)	\
+			ctdb->statistics.counter.min = value;				\
+		if (ctdb->statistics_current.counter.num == 0 || value < ctdb->statistics_current.counter.min)	\
+			ctdb->statistics_current.counter.min = value;			\
+											\
+		ctdb->statistics.counter.total += value;					\
+		ctdb->statistics_current.counter.total += value;				\
+											\
+		ctdb->statistics.counter.num++;						\
+		ctdb->statistics_current.counter.num++;					\
 											\
 		if (ctdb->tunable.reclock_latency_ms != 0) {				\
 			if (value*1000 > ctdb->tunable.reclock_latency_ms) {		\
@@ -320,10 +331,22 @@ struct ctdb_daemon_data {
 #define CTDB_UPDATE_LATENCY(ctdb, db, operation, counter, t) \
 	{										\
 		double l = timeval_elapsed(&t);						\
-		if (l > ctdb->statistics.counter)					\
-			ctdb->statistics.counter = l;					\
-		if (l > ctdb->statistics_current.counter)				\
-			ctdb->statistics_current.counter = l;				\
+											\
+		if (l > ctdb->statistics.counter.max)					\
+			ctdb->statistics.counter.max = l;				\
+		if (l > ctdb->statistics_current.counter.max)				\
+			ctdb->statistics_current.counter.max = l;			\
+											\
+		if (ctdb->statistics.counter.num == 0 || l < ctdb->statistics.counter.min)	\
+			ctdb->statistics.counter.min = l;				\
+		if (ctdb->statistics_current.counter.num == 0 || l < ctdb->statistics_current.counter.min)	\
+			ctdb->statistics_current.counter.min = l;			\
+											\
+		ctdb->statistics.counter.total += l;					\
+		ctdb->statistics_current.counter.total += l;				\
+											\
+		ctdb->statistics.counter.num++;						\
+		ctdb->statistics_current.counter.num++;					\
 											\
 		if (ctdb->tunable.log_latency_ms !=0) {					\
 			if (l*1000 > ctdb->tunable.log_latency_ms) {			\
diff --git a/include/ctdb_protocol.h b/include/ctdb_protocol.h
index 750f1f0..1568460 100644
--- a/include/ctdb_protocol.h
+++ b/include/ctdb_protocol.h
@@ -536,6 +536,13 @@ struct ctdb_all_public_ips {
 };
 
 
+struct latency_counter {
+	int num;
+	double min;
+	double max;
+	double total;
+};
+
 /*
   ctdb statistics information
  */
@@ -570,8 +577,8 @@ struct ctdb_statistics {
 		uint32_t traverse;
 	} timeouts;
 	struct {
-		double ctdbd;
-		double recd;
+		struct latency_counter ctdbd;
+		struct latency_counter recd;
 	} reclock;
 	uint32_t total_calls;
 	uint32_t pending_calls;
@@ -582,9 +589,9 @@ struct ctdb_statistics {
 	uint32_t memory_used;
 	uint32_t __last_counter; /* hack for control_statistics_all */
 	uint32_t max_hop_count;
-	double max_call_latency;
-	double max_lockwait_latency;
-	double max_childwrite_latency;
+	struct latency_counter call_latency;
+	struct latency_counter lockwait_latency;
+	struct latency_counter childwrite_latency;
 	uint32_t num_recoveries;
 	struct timeval statistics_start_time;
 	struct timeval statistics_current_time;
diff --git a/server/ctdb_daemon.c b/server/ctdb_daemon.c
index 16ccaac..12ad954 100644
--- a/server/ctdb_daemon.c
+++ b/server/ctdb_daemon.c
@@ -258,7 +258,7 @@ static void daemon_call_from_client_callback(struct ctdb_call_state *state)
 		DEBUG(DEBUG_ERR, (__location__ " ctdbd_call_recv() returned error\n"));
 		CTDB_DECREMENT_STAT(client->ctdb, pending_calls);
 
-		CTDB_UPDATE_LATENCY(client->ctdb, ctdb_db, "call_from_client_cb 1", max_call_latency, dstate->start_time);
+		CTDB_UPDATE_LATENCY(client->ctdb, ctdb_db, "call_from_client_cb 1", call_latency, dstate->start_time);
 		return;
 	}
 
@@ -268,7 +268,7 @@ static void daemon_call_from_client_callback(struct ctdb_call_state *state)
 	if (r == NULL) {
 		DEBUG(DEBUG_ERR, (__location__ " Failed to allocate reply_call in ctdb daemon\n"));
 		CTDB_DECREMENT_STAT(client->ctdb, pending_calls);
-		CTDB_UPDATE_LATENCY(client->ctdb, ctdb_db, "call_from_client_cb 2", max_call_latency, dstate->start_time);
+		CTDB_UPDATE_LATENCY(client->ctdb, ctdb_db, "call_from_client_cb 2", call_latency, dstate->start_time);
 		return;
 	}
 	r->hdr.reqid        = dstate->reqid;
@@ -283,7 +283,7 @@ static void daemon_call_from_client_callback(struct ctdb_call_state *state)
 	if (res != 0) {
 		DEBUG(DEBUG_ERR, (__location__ " Failed to queue packet from daemon to client\n"));
 	}
-	CTDB_UPDATE_LATENCY(client->ctdb, ctdb_db, "call_from_client_cb 3", max_call_latency, dstate->start_time);
+	CTDB_UPDATE_LATENCY(client->ctdb, ctdb_db, "call_from_client_cb 3", call_latency, dstate->start_time);
 	CTDB_DECREMENT_STAT(client->ctdb, pending_calls);
 	talloc_free(dstate);
 }
@@ -409,7 +409,7 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
 
 		DEBUG(DEBUG_ERR,(__location__ " Unable to allocate call\n"));
 		CTDB_DECREMENT_STAT(ctdb, pending_calls);
-		CTDB_UPDATE_LATENCY(ctdb, ctdb_db, "call_from_client 1", max_call_latency, dstate->start_time);
+		CTDB_UPDATE_LATENCY(ctdb, ctdb_db, "call_from_client 1", call_latency, dstate->start_time);
 		return;
 	}
 
@@ -433,7 +433,7 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
 	if (state == NULL) {
 		DEBUG(DEBUG_ERR,(__location__ " Unable to setup call send\n"));
 		CTDB_DECREMENT_STAT(ctdb, pending_calls);
-		CTDB_UPDATE_LATENCY(ctdb, ctdb_db, "call_from_client 2", max_call_latency, dstate->start_time);
+		CTDB_UPDATE_LATENCY(ctdb, ctdb_db, "call_from_client 2", call_latency, dstate->start_time);
 		return;
 	}
 	talloc_steal(state, dstate);
diff --git a/server/ctdb_lockwait.c b/server/ctdb_lockwait.c
index 9bbc25f..48198fd 100644
--- a/server/ctdb_lockwait.c
+++ b/server/ctdb_lockwait.c
@@ -53,7 +53,7 @@ static void lockwait_handler(struct event_context *ev, struct fd_event *fde,
 	key.dptr = talloc_memdup(tmp_ctx, key.dptr, key.dsize);
 
 	talloc_set_destructor(h, NULL);
-	CTDB_UPDATE_LATENCY(h->ctdb, h->ctdb_db, "lockwait", max_lockwait_latency, h->start_time);
+	CTDB_UPDATE_LATENCY(h->ctdb, h->ctdb_db, "lockwait", lockwait_latency, h->start_time);
 	CTDB_DECREMENT_STAT(h->ctdb, pending_lockwait_calls);
 
 	/* the handle needs to go away when the context is gone - when
diff --git a/server/ctdb_persistent.c b/server/ctdb_persistent.c
index 8672c5b..9346f7d 100644
--- a/server/ctdb_persistent.c
+++ b/server/ctdb_persistent.c
@@ -475,7 +475,7 @@ static void childwrite_handler(struct event_context *ev, struct fd_event *fde,
 	int ret;
 	char c;
 
-	CTDB_UPDATE_LATENCY(h->ctdb, h->ctdb_db, "persistent", max_childwrite_latency, h->start_time);
+	CTDB_UPDATE_LATENCY(h->ctdb, h->ctdb_db, "persistent", childwrite_latency, h->start_time);
 	CTDB_DECREMENT_STAT(h->ctdb, pending_childwrite_calls);
 
 	/* the handle needs to go away when the context is gone - when
diff --git a/server/ctdb_tunables.c b/server/ctdb_tunables.c
index 02e76ae..4a3cfbb 100644
--- a/server/ctdb_tunables.c
+++ b/server/ctdb_tunables.c
@@ -42,7 +42,7 @@ static const struct {
 	{ "EventScriptUnhealthyOnTimeout", 0, offsetof(struct ctdb_tunable, script_unhealthy_on_timeout) },/* OBSOLETE */
 	{ "RecoveryGracePeriod", 120,  offsetof(struct ctdb_tunable, recovery_grace_period) },
 	{ "RecoveryBanPeriod",  300,  offsetof(struct ctdb_tunable, recovery_ban_period) },
-	{ "DatabaseHashSize", 10000,  offsetof(struct ctdb_tunable, database_hash_size) },
+	{ "DatabaseHashSize", 100001, offsetof(struct ctdb_tunable, database_hash_size) },
 	{ "DatabaseMaxDead",      5,  offsetof(struct ctdb_tunable, database_max_dead) },
 	{ "RerecoveryTimeout",   10,  offsetof(struct ctdb_tunable, rerecovery_timeout) },
 	{ "EnableBans",           1,  offsetof(struct ctdb_tunable, enable_bans) },
diff --git a/tools/ctdb.c b/tools/ctdb.c
index 8d42255..0409a40 100644
--- a/tools/ctdb.c
+++ b/tools/ctdb.c
@@ -219,11 +219,29 @@ static void show_statistics(struct ctdb_statistics *s, int show_header)
 			for (i=0;i<ARRAY_SIZE(fields);i++) {
 				printf("%s:", fields[i].name);
 			}
-			printf("max_reclock_ctdbd:");
-			printf("max_reclock_recd:");
+			printf("num_reclock_ctdbd_latency:");
+			printf("min_reclock_ctdbd_latency:");
+			printf("avg_reclock_ctdbd_latency:");
+			printf("max_reclock_ctdbd_latency:");
+
+			printf("num_reclock_recd_latency:");
+			printf("min_reclock_recd_latency:");
+			printf("avg_reclock_recd_latency:");
+			printf("max_reclock_recd_latency:");
+
+			printf("num_call_latency:");
+			printf("min_call_latency:");
+			printf("avg_call_latency:");
 			printf("max_call_latency:");
+
+			printf("num_lockwait_latency:");
+			printf("min_lockwait_latency:");
+			printf("avg_lockwait_latency:");
 			printf("max_lockwait_latency:");
-			printf("max_childwrite_latency:");
+
+			printf("num_childwrite_latency:");
+			printf("min_childwrite_latency:");
+			printf("avg_childwrite_latency:");
 			printf("max_childwrite_latency:");
 			printf("\n");
 		}
@@ -233,12 +251,30 @@ static void show_statistics(struct ctdb_statistics *s, int show_header)
 		for (i=0;i<ARRAY_SIZE(fields);i++) {
 			printf("%d:", *(uint32_t *)(fields[i].offset+(uint8_t *)s));
 		}
-		printf("%.6f:", s->reclock.ctdbd);
-		printf("%.6f:", s->reclock.recd);
-		printf("%.6f:", s->max_call_latency);
-		printf("%.6f:", s->max_lockwait_latency);
-		printf("%.6f:", s->max_childwrite_latency);
-		printf("%.6f:", s->max_childwrite_latency);
+		printf("%d:", s->reclock.ctdbd.num);
+		printf("%.6f:", s->reclock.ctdbd.min);
+		printf("%.6f:", s->reclock.ctdbd.num?s->reclock.ctdbd.total/s->reclock.ctdbd.num:0.0);
+		printf("%.6f:", s->reclock.ctdbd.max);
+
+		printf("%d:", s->reclock.recd.num);
+		printf("%.6f:", s->reclock.recd.min);
+		printf("%.6f:", s->reclock.recd.num?s->reclock.recd.total/s->reclock.recd.num:0.0);
+		printf("%.6f:", s->reclock.recd.max);
+
+		printf("%d:", s->call_latency.num);
+		printf("%.6f:", s->call_latency.min);
+		printf("%.6f:", s->call_latency.num?s->call_latency.total/s->call_latency.num:0.0);
+		printf("%.6f:", s->call_latency.max);
+
+		printf("%d:", s->lockwait_latency.num);
+		printf("%.6f:", s->lockwait_latency.min);
+		printf("%.6f:", s->lockwait_latency.num?s->lockwait_latency.total/s->lockwait_latency.num:0.0);
+		printf("%.6f:", s->lockwait_latency.max);
+
+		printf("%d:", s->childwrite_latency.num);
+		printf("%.6f:", s->childwrite_latency.min);
+		printf("%.6f:", s->childwrite_latency.num?s->childwrite_latency.total/s->childwrite_latency.num:0.0);
+		printf("%.6f:", s->childwrite_latency.max);
 		printf("\n");
 	} else {
 		printf("CTDB version %u\n", CTDB_VERSION);
@@ -261,13 +297,13 @@ static void show_statistics(struct ctdb_statistics *s, int show_header)
 			       preflen?0:4, "",
 			       *(uint32_t *)(fields[i].offset+(uint8_t *)s));
 		}
-		printf(" %-30s     %.6f sec\n", "max_reclock_ctdbd", s->reclock.ctdbd);
-		printf(" %-30s     %.6f sec\n", "max_reclock_recd", s->reclock.recd);
+		printf(" %-30s     %.6f/%.6f/%.6f sec out of %d\n", "reclock_ctdbd       MIN/AVG/MAX", s->reclock.ctdbd.min, s->reclock.ctdbd.num?s->reclock.ctdbd.total/s->reclock.ctdbd.num:0.0, s->reclock.ctdbd.max, s->reclock.ctdbd.num);
+
+		printf(" %-30s     %.6f/%.6f/%.6f sec out of %d\n", "reclock_recd       MIN/AVG/MAX", s->reclock.recd.min, s->reclock.recd.num?s->reclock.recd.total/s->reclock.recd.num:0.0, s->reclock.recd.max, s->reclock.recd.num);
 
-		printf(" %-30s     %.6f sec\n", "max_call_latency", s->max_call_latency);
-		printf(" %-30s     %.6f sec\n", "max_lockwait_latency", s->max_lockwait_latency);
-		printf(" %-30s     %.6f sec\n", "max_childwrite_latency", s->max_childwrite_latency);
-		printf(" %-30s     %.6f sec\n", "max_childwrite_latency", s->max_childwrite_latency);
+		printf(" %-30s     %.6f/%.6f/%.6f sec out of %d\n", "call_latency       MIN/AVG/MAX", s->call_latency.min, s->call_latency.num?s->call_latency.total/s->call_latency.num:0.0, s->call_latency.max, s->call_latency.num);
+		printf(" %-30s     %.6f/%.6f/%.6f sec out of %d\n", "lockwait_latency   MIN/AVG/MAX", s->lockwait_latency.min, s->lockwait_latency.num?s->lockwait_latency.total/s->lockwait_latency.num:0.0, s->lockwait_latency.max, s->lockwait_latency.num);
+		printf(" %-30s     %.6f/%.6f/%.6f sec out of %d\n", "childwrite_latency MIN/AVG/MAX", s->childwrite_latency.min, s->childwrite_latency.num?s->childwrite_latency.total/s->childwrite_latency.num:0.0, s->childwrite_latency.max, s->childwrite_latency.num);
 	}
 
 	talloc_free(tmp_ctx);
@@ -305,10 +341,10 @@ static int control_statistics_all(struct ctdb_context *ctdb)
 		}
 		statistics.max_hop_count = 
 			MAX(statistics.max_hop_count, s1.max_hop_count);
-		statistics.max_call_latency = 
-			MAX(statistics.max_call_latency, s1.max_call_latency);
-		statistics.max_lockwait_latency = 
-			MAX(statistics.max_lockwait_latency, s1.max_lockwait_latency);
+		statistics.call_latency.max = 
+			MAX(statistics.call_latency.max, s1.call_latency.max);
+		statistics.lockwait_latency.max = 
+			MAX(statistics.lockwait_latency.max, s1.lockwait_latency.max);
 	}
 	talloc_free(nodes);
 	printf("Gathered statistics for %u nodes\n", num_nodes);


-- 
CTDB repository


More information about the samba-cvs mailing list