[SCM] CTDB repository - branch master updated - ctdb-1.0.64-4-gb75e226

Ronnie Sahlberg sahlberg at samba.org
Tue Nov 11 03:51:54 GMT 2008


The branch, master has been updated
       via  b75e2263c565c21ecbbd98fbd2c10787e467bf5c (commit)
       via  aba984f1b85f5a2d370b093061cf15843ee53758 (commit)
       via  8c6a02fb423a8cbcbfc706767e3d353cd48073c3 (commit)
       via  1d581dcd507e8e13d7ae085ff4d6a9f3e2aaeba5 (commit)
      from  1a7ff4577d33f0dd470f7465c7d0e875c962f54e (commit)

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


- Log -----------------------------------------------------------------
commit b75e2263c565c21ecbbd98fbd2c10787e467bf5c
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Nov 11 14:49:30 2008 +1100

    add a CTDB_SOCKET variable that can be used to override the default
    /tmp/ctdb.socket

commit aba984f1b85f5a2d370b093061cf15843ee53758
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Mon Nov 3 21:54:52 2008 +1100

    we actually need a ctdb_db variable

commit 8c6a02fb423a8cbcbfc706767e3d353cd48073c3
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Thu Oct 30 13:34:10 2008 +1100

    latency is measured in us, not ms
    
    use an explicit ctdb_db variable instead of dereferencing state

commit 1d581dcd507e8e13d7ae085ff4d6a9f3e2aaeba5
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Thu Oct 30 12:49:53 2008 +1100

    add control and logging of very high latencies.
    
    log the type of operation and the database name for all latencies higher
    than a treshold

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

Summary of changes:
 client/ctdb_client.c     |    1 +
 common/cmdline.c         |   31 +++++++++++++++++++++----------
 common/ctdb_util.c       |    8 +++++++-
 include/ctdb_private.h   |    3 ++-
 server/ctdb_daemon.c     |   11 ++++++-----
 server/ctdb_lockwait.c   |    2 +-
 server/ctdb_persistent.c |    2 +-
 server/ctdb_tunables.c   |    1 +
 tests/nodes.txt          |    3 +++
 9 files changed, 43 insertions(+), 19 deletions(-)


Changeset truncated at 500 lines:

diff --git a/client/ctdb_client.c b/client/ctdb_client.c
index 07c0b88..fcd10b2 100644
--- a/client/ctdb_client.c
+++ b/client/ctdb_client.c
@@ -26,6 +26,7 @@
 #include "system/network.h"
 #include "system/filesys.h"
 #include "system/locale.h"
+#include <stdlib.h>
 #include "../include/ctdb_private.h"
 #include "lib/util/dlinklist.h"
 
diff --git a/common/cmdline.c b/common/cmdline.c
index b6e3541..ea81faf 100644
--- a/common/cmdline.c
+++ b/common/cmdline.c
@@ -33,7 +33,6 @@ static struct {
 	int torture;
 	const char *events;
 } ctdb_cmdline = {
-	.socketname = CTDB_PATH,
 	.torture = 0,
 };
 
@@ -81,11 +80,14 @@ struct ctdb_context *ctdb_cmdline_init(struct event_context *ev)
 		ctdb_set_flags(ctdb, CTDB_FLAG_TORTURE);
 	}
 
-	/* tell ctdb the socket address */
-	ret = ctdb_set_socketname(ctdb, ctdb_cmdline.socketname);
-	if (ret == -1) {
-		printf("ctdb_set_socketname failed - %s\n", ctdb_errstr(ctdb));
-		exit(1);
+	/* command line specified a socket name */
+	if (ctdb_cmdline.socketname != NULL) {
+		ret = ctdb_set_socketname(ctdb, ctdb_cmdline.socketname);
+		if (ret == -1) {
+			printf("ctdb_set_socketname failed - %s\n",
+						    ctdb_errstr(ctdb));
+			exit(1);
+		}
 	}
 
 	/* set up the tree to store server ids */
@@ -101,6 +103,7 @@ struct ctdb_context *ctdb_cmdline_init(struct event_context *ev)
 struct ctdb_context *ctdb_cmdline_client(struct event_context *ev)
 {
 	struct ctdb_context *ctdb;
+	char *socket_name;
 	int ret;
 
 	/* initialise ctdb */
@@ -111,10 +114,18 @@ struct ctdb_context *ctdb_cmdline_client(struct event_context *ev)
 	}
 
 	/* tell ctdb the socket address */
-	ret = ctdb_set_socketname(ctdb, ctdb_cmdline.socketname);
-	if (ret == -1) {
-		fprintf(stderr, "ctdb_set_socketname failed - %s\n", ctdb_errstr(ctdb));
-		exit(1);
+	socket_name = getenv("CTDB_SOCKET");
+	if (socket_name != NULL) {
+		ctdb_set_socketname(ctdb, socket_name);
+	}
+
+	if (ctdb_cmdline.socketname != NULL) {
+		ret = ctdb_set_socketname(ctdb, ctdb_cmdline.socketname);
+		if (ret == -1) {
+			fprintf(stderr, "ctdb_set_socketname failed - %s\n",
+					ctdb_errstr(ctdb));
+			exit(1);
+		}
 	}
 
 	ret = ctdb_socket_connect(ctdb);
diff --git a/common/ctdb_util.c b/common/ctdb_util.c
index 7c2b171..b5a3508 100644
--- a/common/ctdb_util.c
+++ b/common/ctdb_util.c
@@ -124,12 +124,18 @@ static void *_idr_find_type(struct idr_context *idp, int id, const char *type, c
 /*
   update a max latency number
  */
-void ctdb_latency(double *latency, struct timeval t)
+void ctdb_latency(struct ctdb_db_context *ctdb_db, const char *name, double *latency, struct timeval t)
 {
 	double l = timeval_elapsed(&t);
 	if (l > *latency) {
 		*latency = l;
 	}
+
+	if (ctdb_db->ctdb->tunable.log_latency_ms !=0) {
+		if (l*1000 > ctdb_db->ctdb->tunable.log_latency_ms) {
+			DEBUG(DEBUG_WARNING, ("High latency %fs for operation %s on database %s\n", l*1000000, name, ctdb_db->db_name));
+		}
+	}
 }
 
 uint32_t ctdb_reqid_new(struct ctdb_context *ctdb, void *state)
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index 9c06409..f526f26 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -116,6 +116,7 @@ struct ctdb_tunable {
 	uint32_t verbose_memory_names;
 	uint32_t recd_ping_timeout;
 	uint32_t recd_ping_failcount;
+	uint32_t log_latency_ms;
 };
 
 /*
@@ -967,7 +968,7 @@ void ctdb_recv_raw_pkt(void *p, uint8_t *data, uint32_t length);
 
 int ctdb_socket_connect(struct ctdb_context *ctdb);
 
-void ctdb_latency(double *latency, struct timeval t);
+void ctdb_latency(struct ctdb_db_context *ctdb_db, const char *name, double *latency, struct timeval t);
 
 uint32_t ctdb_reqid_new(struct ctdb_context *ctdb, void *state);
 void *_ctdb_reqid_find(struct ctdb_context *ctdb, uint32_t reqid, const char *type, const char *location);
diff --git a/server/ctdb_daemon.c b/server/ctdb_daemon.c
index 885ce7e..8ddda70 100644
--- a/server/ctdb_daemon.c
+++ b/server/ctdb_daemon.c
@@ -269,6 +269,7 @@ static void daemon_call_from_client_callback(struct ctdb_call_state *state)
 	int res;
 	uint32_t length;
 	struct ctdb_client *client = dstate->client;
+	struct ctdb_db_context *ctdb_db = state->ctdb_db;
 
 	talloc_steal(client, dstate);
 	talloc_steal(dstate, dstate->call);
@@ -277,7 +278,7 @@ static void daemon_call_from_client_callback(struct ctdb_call_state *state)
 	if (res != 0) {
 		DEBUG(DEBUG_ERR, (__location__ " ctdbd_call_recv() returned error\n"));
 		client->ctdb->statistics.pending_calls--;
-		ctdb_latency(&client->ctdb->statistics.max_call_latency, dstate->start_time);
+		ctdb_latency(ctdb_db, "call_from_client_cb 1", &client->ctdb->statistics.max_call_latency, dstate->start_time);
 		return;
 	}
 
@@ -287,7 +288,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"));
 		client->ctdb->statistics.pending_calls--;
-		ctdb_latency(&client->ctdb->statistics.max_call_latency, dstate->start_time);
+		ctdb_latency(ctdb_db, "call_from_client_cb 2", &client->ctdb->statistics.max_call_latency, dstate->start_time);
 		return;
 	}
 	r->hdr.reqid        = dstate->reqid;
@@ -298,7 +299,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_latency(&client->ctdb->statistics.max_call_latency, dstate->start_time);
+	ctdb_latency(ctdb_db, "call_from_client_cb 3", &client->ctdb->statistics.max_call_latency, dstate->start_time);
 	talloc_free(dstate);
 	client->ctdb->statistics.pending_calls--;
 }
@@ -406,7 +407,7 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
 		ctdb_ltdb_unlock(ctdb_db, key);
 		DEBUG(DEBUG_ERR,(__location__ " Unable to allocate call\n"));
 		ctdb->statistics.pending_calls--;
-		ctdb_latency(&ctdb->statistics.max_call_latency, dstate->start_time);
+		ctdb_latency(ctdb_db, "call_from_client 1", &ctdb->statistics.max_call_latency, dstate->start_time);
 		return;
 	}
 
@@ -427,7 +428,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->statistics.pending_calls--;
-		ctdb_latency(&ctdb->statistics.max_call_latency, dstate->start_time);
+		ctdb_latency(ctdb_db, "call_from_client 2", &ctdb->statistics.max_call_latency, dstate->start_time);
 		return;
 	}
 	talloc_steal(state, dstate);
diff --git a/server/ctdb_lockwait.c b/server/ctdb_lockwait.c
index 03a7eed..be3a097 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_latency(&h->ctdb->statistics.max_lockwait_latency, h->start_time);
+	ctdb_latency(h->ctdb_db, "lockwait", &h->ctdb->statistics.max_lockwait_latency, h->start_time);
 	h->ctdb->statistics.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 42b148c..7df702b 100644
--- a/server/ctdb_persistent.c
+++ b/server/ctdb_persistent.c
@@ -330,7 +330,7 @@ static void childwrite_handler(struct event_context *ev, struct fd_event *fde,
 	int ret;
 	char c;
 
-	ctdb_latency(&h->ctdb->statistics.max_childwrite_latency, h->start_time);
+	ctdb_latency(h->ctdb_db, "persistent", &h->ctdb->statistics.max_childwrite_latency, h->start_time);
 	h->ctdb->statistics.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 cc8e067..f758c2c 100644
--- a/server/ctdb_tunables.c
+++ b/server/ctdb_tunables.c
@@ -52,6 +52,7 @@ static const struct {
 	{ "VerboseMemoryNames",   0,  offsetof(struct ctdb_tunable, verbose_memory_names) },
 	{ "RecdPingTimeout",	 20,  offsetof(struct ctdb_tunable, recd_ping_timeout) },
 	{ "RecdFailCount",	  3,  offsetof(struct ctdb_tunable, recd_ping_failcount) },
+	{ "LogLatencyMs",         0,  offsetof(struct ctdb_tunable, log_latency_ms) },
 };
 
 /*
diff --git a/tests/nodes.txt b/tests/nodes.txt
index 7b9ad53..99b0732 100644
--- a/tests/nodes.txt
+++ b/tests/nodes.txt
@@ -1 +1,4 @@
 127.0.0.1
+127.0.0.2
+127.0.0.3
+127.0.0.4


-- 
CTDB repository


More information about the samba-cvs mailing list