cluster: STABLE3 - rgmanager: Make VF timeout scale with token timeout

Lon Hohberger lon at fedoraproject.org
Fri Feb 19 15:14:47 UTC 2010


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=5ed49a26ac09148993799eecae15eaa6d6623984
Commit:        5ed49a26ac09148993799eecae15eaa6d6623984
Parent:        f504ce0183dba5ab86ac70b56ca39399f87eb347
Author:        Lon Hohberger <lhh at redhat.com>
AuthorDate:    Wed Dec 16 12:56:43 2009 -0500
Committer:     Lon Hohberger <lhh at redhat.com>
CommitterDate: Fri Feb 19 10:14:15 2010 -0500

rgmanager: Make VF timeout scale with token timeout

Rgmanager was not waiting long enough to account for
failures mid-state transition, allowing the possibility
for services to enter the 'failed' state erroneously.

Resolves: rhbz#548133

Signed-off-by: Lon Hohberger <lhh at redhat.com>
---
 rgmanager/include/vf.h       |    2 +-
 rgmanager/src/clulib/vft.c   |    7 +++++--
 rgmanager/src/daemons/main.c |   22 +++++++++++++++++-----
 3 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/rgmanager/include/vf.h b/rgmanager/include/vf.h
index 528930c..d57b0cf 100644
--- a/rgmanager/include/vf.h
+++ b/rgmanager/include/vf.h
@@ -152,7 +152,7 @@ typedef struct _key_node {
 /* 
  * VF Stuff.  VF only talks to peers.
  */
-int vf_init(int, uint16_t, vf_vote_cb_t, vf_commit_cb_t);
+int vf_init(int, uint16_t, vf_vote_cb_t, vf_commit_cb_t, int);
 int vf_invalidate(void);
 int vf_shutdown(void);
 
diff --git a/rgmanager/src/clulib/vft.c b/rgmanager/src/clulib/vft.c
index eefba2f..9c78a12 100644
--- a/rgmanager/src/clulib/vft.c
+++ b/rgmanager/src/clulib/vft.c
@@ -27,6 +27,7 @@
 static key_node_t *key_list = NULL;	/** List of key nodes. */
 static int _node_id = (int)-1;/** Our node ID, set with vf_init. */
 static uint16_t _port = 0;		/** Our daemon ID, set with vf_init. */
+static int _vf_timeout = 10;
 
 /*
  * TODO: We could make it thread safe, but this might be unnecessary work
@@ -884,7 +885,7 @@ vf_server(void *arg)
  */
 int
 vf_init(int my_node_id, uint16_t my_port, vf_vote_cb_t vcb,
-	vf_commit_cb_t ccb)
+	vf_commit_cb_t ccb, int cluster_timeout)
 {
 	struct vf_args *args;
 	msgctx_t *ctx;
@@ -911,6 +912,8 @@ vf_init(int my_node_id, uint16_t my_port, vf_vote_cb_t vcb,
 	pthread_mutex_lock(&vf_mutex);
 	_port = my_port;
 	_node_id = my_node_id;
+	if (cluster_timeout)
+		_vf_timeout = cluster_timeout;
 	default_vote_cb = vcb;
 	default_commit_cb = ccb;
 	pthread_mutex_unlock(&vf_mutex);
@@ -1223,7 +1226,7 @@ vf_write(cluster_member_list_t *membership, uint32_t flags,
 	 * See if we have a consensus =)
 	 */
 	if ((rv = (vf_unanimous(&everyone, trans, remain,
-				5))) == VFR_OK) {
+				_vf_timeout))) == VFR_OK) {
 		vf_send_commit(&everyone, trans);
 #ifdef DEBUG
 		printf("VF: Consensus reached!\n");
diff --git a/rgmanager/src/daemons/main.c b/rgmanager/src/daemons/main.c
index 885d89d..3b73be8 100644
--- a/rgmanager/src/daemons/main.c
+++ b/rgmanager/src/daemons/main.c
@@ -27,7 +27,7 @@
 #ifdef WRAP_THREADS
 void dump_thread_states(FILE *);
 #endif
-static int configure_rgmanager(int ccsfd, int debug);
+static int configure_rgmanager(int ccsfd, int debug, int *cluster_timeout);
 void set_transition_throttling(int);
 
 void flag_shutdown(int sig);
@@ -742,7 +742,7 @@ event_loop(msgctx_t *localctx, msgctx_t *clusterctx)
 
 	if (need_reconfigure) {
 		need_reconfigure = 0;
-		configure_rgmanager(-1, 0);
+		configure_rgmanager(-1, 0, NULL);
 		config_event_q();
 		return 0;
 	}
@@ -788,11 +788,12 @@ statedump(int __attribute__ ((unused)) sig)
  * Configure logging based on data in cluster.conf
  */
 static int
-configure_rgmanager(int ccsfd, int dbg)
+configure_rgmanager(int ccsfd, int dbg, int *token_secs)
 {
 	char *v;
 	char internal = 0;
 	int status_child_max = 0;
+	int tmp;
 
 	if (ccsfd < 0) {
 		internal = 1;
@@ -803,6 +804,16 @@ configure_rgmanager(int ccsfd, int dbg)
 
 	setup_logging(ccsfd);
 
+	if (token_secs && ccs_get(ccsfd, "/cluster/totem/@token", &v) == 0) {
+		tmp = atoi(v);
+		if (tmp >= 1000) {
+			*token_secs = tmp / 1000;
+			if (tmp % 1000)
+				++(*token_secs);
+		}
+		free(v);
+	}
+
 	if (ccs_get(ccsfd, "/cluster/rm/@transition_throttling", &v) == 0) {
 		set_transition_throttling(atoi(v));
 		free(v);
@@ -937,6 +948,7 @@ main(int argc, char **argv)
 	msgctx_t *local_ctx;
 	pthread_t th;
 	cman_handle_t clu = NULL;
+	int cluster_timeout = 10;
 
 	while ((rv = getopt(argc, argv, "wfdN")) != EOF) {
 		switch (rv) {
@@ -1018,7 +1030,7 @@ main(int argc, char **argv)
 	   We know we're quorate.  At this point, we need to
 	   read the resource group trees from ccsd.
 	 */
-	configure_rgmanager(-1, debug);
+	configure_rgmanager(-1, debug, &cluster_timeout);
 	logt_print(LOG_NOTICE, "Resource Group Manager Starting\n");
 
 	if (init_resource_groups(0, do_init) != 0) {
@@ -1063,7 +1075,7 @@ main(int argc, char **argv)
 
 	ds_key_init("rg_lockdown", 32, 10);
 #else
-	if (vf_init(me.cn_nodeid, port, NULL, NULL) != 0) {
+	if (vf_init(me.cn_nodeid, port, NULL, NULL, cluster_timeout) != 0) {
 		logt_print(LOG_CRIT, "#11: Couldn't set up VF listen socket\n");
 		goto out_ls;
 	}


More information about the cluster-commits mailing list