From 31228f924b6d6645a8bd2869a8180abe74617375 Mon Sep 17 00:00:00 2001 From: Sanju Rakonde Date: Sat, 2 Jun 2018 16:36:22 +0530 Subject: glusterd: gluster v status is showing wrong status for glustershd When we restart the bricks, connect and disconnect events happen for glustershd. glusterd use two threads to handle disconnect and connects events from glustershd. When we restart the bricks we'll get both disconnect and connect events. So both the threads will compete for the big lock. We want disconnect event to finish before connect event. But If connect thread gets the big lock first, it sets svc->online to true, and then disconnect thread will et svc->online to false. So, glustershd will be disconnected from glusterd and wrong status is shown. After killing shd, glusterd sleeps for 1 second. To avoid the problem, If glusterd releses the lock before sleep and acquires it after sleep, disconnect thread will get a chance to handle the glusterd_svc_common_rpc_notify before other thread completes connect event. >Change-Id: Ie82e823fdfc936feb7c0ae10599297b050ee9986 >Signed-off-by: Sanju Rakonde Change-Id: Ie82e823fdfc936feb7c0ae10599297b050ee9986 fixes: bz#1582443 Signed-off-by: Sanju Rakonde --- xlators/mgmt/glusterd/src/glusterd-proc-mgmt.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-proc-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-proc-mgmt.c index 8eeec403139..7400dafc7fa 100644 --- a/xlators/mgmt/glusterd/src/glusterd-proc-mgmt.c +++ b/xlators/mgmt/glusterd/src/glusterd-proc-mgmt.c @@ -12,6 +12,7 @@ #include #include +#include "glusterd.h" #include "common-utils.h" #include "xlator.h" #include "logging.h" @@ -69,13 +70,17 @@ glusterd_proc_stop (glusterd_proc_t *proc, int sig, int flags) /* NB: Copy-paste code from glusterd_service_stop, the source may be * removed once all daemon management use proc */ - int32_t ret = -1; - pid_t pid = -1; - xlator_t *this = NULL; + int32_t ret = -1; + pid_t pid = -1; + xlator_t *this = NULL; + glusterd_conf_t *conf = NULL; this = THIS; GF_ASSERT (this); + conf = this->private; + GF_ASSERT (conf); + if (!gf_is_service_running (proc->pidfile, &pid)) { ret = 0; gf_msg (this->name, GF_LOG_INFO, 0, @@ -104,7 +109,9 @@ glusterd_proc_stop (glusterd_proc_t *proc, int sig, int flags) if (flags != PROC_STOP_FORCE) goto out; + synclock_unlock (&conf->big_lock); sleep (1); + synclock_lock (&conf->big_lock); if (gf_is_service_running (proc->pidfile, &pid)) { ret = kill (pid, SIGKILL); if (ret) { -- cgit