Rev 459: make recovery daemon values tunable in http://samba.org/~tridge/ctdb

tridge at samba.org tridge at samba.org
Mon Jun 4 10:22:45 GMT 2007


------------------------------------------------------------
revno: 459
revision-id: tridge at samba.org-20070604102244-fsw0ujymz76j2qd1
parent: tridge at samba.org-20070604100531-doyjw8gu3hnyvvug
committer: Andrew Tridgell <tridge at samba.org>
branch nick: tridge
timestamp: Mon 2007-06-04 20:22:44 +1000
message:
  make recovery daemon values tunable
modified:
  common/ctdb.c                  ctdb.c-20061127094323-t50f58d65iaao5of-2
  common/ctdb_recoverd.c         recoverd.c-20070503213540-bvxuyd9jm1f7ig90-1
  common/ctdb_tunables.c         ctdb_tunables.c-20070604095258-4m34d7cm1qa7yos9-1
  include/ctdb_private.h         ctdb_private.h-20061117234101-o3qt14umlg9en8z0-13
=== modified file 'common/ctdb.c'
--- a/common/ctdb.c	2007-06-04 07:46:37 +0000
+++ b/common/ctdb.c	2007-06-04 10:22:44 +0000
@@ -523,14 +523,7 @@
 	ctdb->recovery_lock_fd = -1;
 	ctdb->monitoring_mode  = CTDB_MONITORING_ACTIVE;
 
-	/* set default values for tunables */
-	ctdb->tunable.max_redirect_count = 3;
-	ctdb->tunable.seqnum_frequency   = 1;
-	ctdb->tunable.control_timeout    = 60;
-	ctdb->tunable.traverse_timeout   = 20;
-	ctdb->tunable.monitoring_timeout = 2;
-	ctdb->tunable.monitoring_limit   = 3;
-	ctdb->tunable.max_lacount        = 7;
+	ctdb_tunables_set_defaults(ctdb);
 
 	return ctdb;
 }

=== modified file 'common/ctdb_recoverd.c'
--- a/common/ctdb_recoverd.c	2007-06-03 00:29:14 +0000
+++ b/common/ctdb_recoverd.c	2007-06-04 10:22:44 +0000
@@ -35,8 +35,8 @@
 	timed_out = 1;
 }
 
-#define CONTROL_TIMEOUT() timeval_current_ofs(5, 0)
-#define MONITOR_TIMEOUT() timeval_current_ofs(1, 0)
+#define CONTROL_TIMEOUT() timeval_current_ofs(ctdb->tunable.recover_timeout, 0)
+#define MONITOR_TIMEOUT() timeval_current_ofs(ctdb->tunable.monitor_frequency, 0)
 
 static int set_recovery_mode(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap, uint32_t rec_mode)
 {
@@ -50,7 +50,7 @@
 		}
 
 		if (rec_mode == CTDB_RECOVERY_ACTIVE) {
-			ret = ctdb_ctrl_freeze(ctdb, timeval_current_ofs(5, 0), nodemap->nodes[j].vnn);
+			ret = ctdb_ctrl_freeze(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].vnn);
 			if (ret != 0) {
 				DEBUG(0, (__location__ " Unable to freeze node %u\n", nodemap->nodes[j].vnn));
 				return -1;
@@ -64,7 +64,7 @@
 		}
 
 		if (rec_mode == CTDB_RECOVERY_NORMAL) {
-			ret = ctdb_ctrl_thaw(ctdb, timeval_current_ofs(5, 0), nodemap->nodes[j].vnn);
+			ret = ctdb_ctrl_thaw(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].vnn);
 			if (ret != 0) {
 				DEBUG(0, (__location__ " Unable to thaw node %u\n", nodemap->nodes[j].vnn));
 				return -1;
@@ -652,14 +652,16 @@
 
 	/* wait for a few seconds to collect all responses */
 	timed_out = 0;
-	event_add_timed(ctdb->ev, mem_ctx, timeval_current_ofs(3, 0), 
+	event_add_timed(ctdb->ev, mem_ctx, timeval_current_ofs(ctdb->tunable.election_timeout, 0),
 			timeout_func, ctdb);
 	while (!timed_out) {
 		event_loop_once(ctdb->ev);
 	}
 }
 
-
+/*
+  the main monitoring loop
+ */
 void monitor_cluster(struct ctdb_context *ctdb)
 {
 	uint32_t vnn, num_active, recmode, recmaster;
@@ -688,6 +690,14 @@
 		event_loop_once(ctdb->ev);
 	}
 
+	/* get relevant tunables */
+	ctdb_ctrl_get_tunable(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, 
+			      "RecoverTimeout", &ctdb->tunable.recover_timeout);
+	ctdb_ctrl_get_tunable(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, 
+			      "MonitorFrequency", &ctdb->tunable.monitor_frequency);
+	ctdb_ctrl_get_tunable(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, 
+			      "ElectionTimeout", &ctdb->tunable.election_timeout);
+
 	vnn = ctdb_ctrl_getvnn(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE);
 	if (vnn == (uint32_t)-1) {
 		DEBUG(0,("Failed to get local vnn - retrying\n"));

=== modified file 'common/ctdb_tunables.c'
--- a/common/ctdb_tunables.c	2007-06-04 09:53:19 +0000
+++ b/common/ctdb_tunables.c	2007-06-04 10:22:44 +0000
@@ -22,17 +22,32 @@
 
 static const struct {
 	const char *name;
-	size_t offset;
+	uint32_t default_v;
+	size_t offset;	
 } tunable_map[] = {
-	{ "MaxRedirectCount",  offsetof(struct ctdb_tunable, max_redirect_count) },
-	{ "SeqnumFrequency",   offsetof(struct ctdb_tunable, seqnum_frequency) },
-	{ "ControlTimeout",    offsetof(struct ctdb_tunable, control_timeout) },
-	{ "TraverseTimeout",   offsetof(struct ctdb_tunable, traverse_timeout) },
-	{ "MonitoringTimeout", offsetof(struct ctdb_tunable, monitoring_timeout) },
-	{ "MonitoringLimit",   offsetof(struct ctdb_tunable, monitoring_limit) },
-	{ "MaxLACount",        offsetof(struct ctdb_tunable, max_lacount) },
+	{ "MaxRedirectCount",  3,  offsetof(struct ctdb_tunable, max_redirect_count) },
+	{ "SeqnumFrequency",   1,  offsetof(struct ctdb_tunable, seqnum_frequency) },
+	{ "ControlTimeout",    60, offsetof(struct ctdb_tunable, control_timeout) },
+	{ "TraverseTimeout",   20, offsetof(struct ctdb_tunable, traverse_timeout) },
+	{ "MonitoringTimeout", 2,  offsetof(struct ctdb_tunable, monitoring_timeout) },
+	{ "MonitoringLimit",   3,  offsetof(struct ctdb_tunable, monitoring_limit) },
+	{ "MaxLACount",        7,  offsetof(struct ctdb_tunable, max_lacount) },
+	{ "RecoverTimeout",    5,  offsetof(struct ctdb_tunable, recover_timeout) },
+	{ "MonitorFrequency",  1,  offsetof(struct ctdb_tunable, monitor_frequency) },
+	{ "ElectionTimeout",   3,  offsetof(struct ctdb_tunable, election_timeout) },
 };
 
+/*
+  set all tunables to defaults
+ */
+void ctdb_tunables_set_defaults(struct ctdb_context *ctdb)
+{
+	int i;
+	for (i=0;i<ARRAY_SIZE(tunable_map);i++) {
+		*(uint32_t *)(tunable_map[i].offset + (uint8_t*)&ctdb->tunable) = tunable_map[i].default_v;
+	}
+}
+
 
 /*
   get a tunable

=== modified file 'include/ctdb_private.h'
--- a/include/ctdb_private.h	2007-06-04 09:53:19 +0000
+++ b/include/ctdb_private.h	2007-06-04 10:22:44 +0000
@@ -47,6 +47,9 @@
 	uint32_t monitoring_timeout;
 	uint32_t monitoring_limit;
 	uint32_t max_lacount;
+	uint32_t recover_timeout;
+	uint32_t monitor_frequency;
+	uint32_t election_timeout;
 };
 
 /*
@@ -971,4 +974,6 @@
 int32_t ctdb_control_set_tunable(struct ctdb_context *ctdb, TDB_DATA indata);
 int32_t ctdb_control_list_tunables(struct ctdb_context *ctdb, TDB_DATA *outdata);
 
+void ctdb_tunables_set_defaults(struct ctdb_context *ctdb);
+
 #endif



More information about the samba-cvs mailing list