[sheepdog] [PATCH V2] sheep: remove check_majority()

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Wed May 16 13:54:01 CEST 2012


At Wed, 16 May 2012 17:46:54 +0800,
Yunkai Zhang wrote:
> 
> From: Yunkai Zhang <qiushu.zyk at taobao.com>
> 
> When sheep receives LEAVE event, check_majority() will be executed in
> __sd_leave(), it'll make network very busy as it try to connect all
> sheeps each other.
> 
> I don't think this checking is necessary, that is driver's work. Driver
> will tell us which sheep is alive and which have left. So let's remove
> this checking.

I also think it's the right way to go to check network partition in
cluster drivers, but the corosync driver doesn't support it yet.  Is
it possible to implement a network partition handling in the corosync
driver before removing the code from __sd_leave()?  There are already
some users who use Sheepdog with corosync.

Thanks,

Kazutaka

> 
> Signed-off-by: Yunkai Zhang <qiushu.zyk at taobao.com>
> ---
>  sheep/group.c |   39 ---------------------------------------
>  1 files changed, 0 insertions(+), 39 deletions(-)
> 
> diff --git a/sheep/group.c b/sheep/group.c
> index e37e049..e952265 100644
> --- a/sheep/group.c
> +++ b/sheep/group.c
> @@ -668,39 +668,6 @@ void sd_notify_handler(struct sd_node *sender, void *msg, size_t msg_len)
>  	process_request_event_queues();
>  }
>  
> -/*
> - * Check whether the majority of Sheepdog nodes are still alive or not
> - */
> -static int check_majority(struct sd_node *nodes, int nr_nodes)
> -{
> -	int nr_majority, nr_reachable = 0, fd, i;
> -	char name[INET6_ADDRSTRLEN];
> -
> -	nr_majority = nr_nodes / 2 + 1;
> -
> -	/* we need at least 3 nodes to handle network partition
> -	 * failure */
> -	if (nr_nodes < 3)
> -		return 1;
> -
> -	for (i = 0; i < nr_nodes; i++) {
> -		addr_to_str(name, sizeof(name), nodes[i].addr, 0);
> -		fd = connect_to(name, nodes[i].port);
> -		if (fd < 0)
> -			continue;
> -
> -		close(fd);
> -		nr_reachable++;
> -		if (nr_reachable >= nr_majority) {
> -			dprintf("the majority of nodes are alive\n");
> -			return 1;
> -		}
> -	}
> -	dprintf("%d, %d, %d\n", nr_nodes, nr_majority, nr_reachable);
> -	eprintf("the majority of nodes are not alive\n");
> -	return 0;
> -}
> -
>  static void __sd_join(struct event_struct *cevent)
>  {
>  	struct work_join *w = container_of(cevent, struct work_join, cev);
> @@ -729,12 +696,6 @@ static void __sd_join(struct event_struct *cevent)
>  
>  static void __sd_leave(struct event_struct *cevent)
>  {
> -	struct work_leave *w = container_of(cevent, struct work_leave, cev);
> -
> -	if (!check_majority(w->member_list, w->member_list_entries)) {
> -		eprintf("perhaps a network partition has occurred?\n");
> -		abort();
> -	}
>  }
>  
>  enum cluster_join_result sd_check_join_cb(struct sd_node *joining, void *opaque)
> -- 
> 1.7.7.6
> 
> -- 
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog



More information about the sheepdog mailing list