|
|
14f8ab |
From 646292b4f73bf1b506d034b85787f794963d7196 Mon Sep 17 00:00:00 2001
|
|
|
14f8ab |
From: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
14f8ab |
Date: Mon, 6 May 2019 23:35:08 +0530
|
|
|
14f8ab |
Subject: [PATCH 137/141] shd/glusterd: Serialize shd manager to prevent race
|
|
|
14f8ab |
condition
|
|
|
14f8ab |
|
|
|
14f8ab |
At the time of a glusterd restart, while doing a handshake
|
|
|
14f8ab |
there is a possibility that multiple shd manager might get
|
|
|
14f8ab |
executed. Because of this, there is a chance that multiple
|
|
|
14f8ab |
shd get spawned during a glusterd restart
|
|
|
14f8ab |
|
|
|
14f8ab |
> upstream patch : https://review.gluster.org/#/c/glusterfs/+/22667/
|
|
|
14f8ab |
|
|
|
14f8ab |
>Change-Id: Ie20798441e07d7d7a93b7d38dfb924cea178a920
|
|
|
14f8ab |
>fixes: bz#1707081
|
|
|
14f8ab |
>Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
14f8ab |
|
|
|
14f8ab |
BUG: 1704851
|
|
|
14f8ab |
Change-Id: Ie20798441e07d7d7a93b7d38dfb924cea178a920
|
|
|
14f8ab |
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
14f8ab |
Reviewed-on: https://code.engineering.redhat.com/gerrit/169947
|
|
|
14f8ab |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
14f8ab |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
14f8ab |
---
|
|
|
14f8ab |
.../serialize-shd-manager-glusterd-restart.t | 54 ++++++++++++++++++++++
|
|
|
14f8ab |
xlators/mgmt/glusterd/src/glusterd-shd-svc.c | 14 ++++++
|
|
|
14f8ab |
xlators/mgmt/glusterd/src/glusterd.c | 1 +
|
|
|
14f8ab |
xlators/mgmt/glusterd/src/glusterd.h | 3 ++
|
|
|
14f8ab |
4 files changed, 72 insertions(+)
|
|
|
14f8ab |
create mode 100644 tests/bugs/glusterd/serialize-shd-manager-glusterd-restart.t
|
|
|
14f8ab |
|
|
|
14f8ab |
diff --git a/tests/bugs/glusterd/serialize-shd-manager-glusterd-restart.t b/tests/bugs/glusterd/serialize-shd-manager-glusterd-restart.t
|
|
|
14f8ab |
new file mode 100644
|
|
|
14f8ab |
index 0000000..3a27c2a
|
|
|
14f8ab |
--- /dev/null
|
|
|
14f8ab |
+++ b/tests/bugs/glusterd/serialize-shd-manager-glusterd-restart.t
|
|
|
14f8ab |
@@ -0,0 +1,54 @@
|
|
|
14f8ab |
+#! /bin/bash
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+. $(dirname $0)/../../include.rc
|
|
|
14f8ab |
+. $(dirname $0)/../../cluster.rc
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+function check_peers {
|
|
|
14f8ab |
+count=`$CLI_1 peer status | grep 'Peer in Cluster (Connected)' | wc -l`
|
|
|
14f8ab |
+echo $count
|
|
|
14f8ab |
+}
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+function check_shd {
|
|
|
14f8ab |
+ps aux | grep $1 | grep glustershd | wc -l
|
|
|
14f8ab |
+}
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+cleanup
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+TEST launch_cluster 6
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+TESTS_EXPECTED_IN_LOOP=25
|
|
|
14f8ab |
+for i in $(seq 2 6); do
|
|
|
14f8ab |
+ hostname="H$i"
|
|
|
14f8ab |
+ TEST $CLI_1 peer probe ${!hostname}
|
|
|
14f8ab |
+done
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+EXPECT_WITHIN $PROBE_TIMEOUT 5 check_peers;
|
|
|
14f8ab |
+for i in $(seq 1 5); do
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ TEST $CLI_1 volume create ${V0}_$i replica 3 $H1:$B1/${V0}_$i $H2:$B2/${V0}_$i $H3:$B3/${V0}_$i $H4:$B4/${V0}_$i $H5:$B5/${V0}_$i $H6:$B6/${V0}_$i
|
|
|
14f8ab |
+ TEST $CLI_1 volume start ${V0}_$i force
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+done
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+#kill a node
|
|
|
14f8ab |
+TEST kill_node 3
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+TEST $glusterd_3;
|
|
|
14f8ab |
+EXPECT_WITHIN $PROBE_TIMEOUT 5 check_peers
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT 1 check_shd $H3
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+for i in $(seq 1 5); do
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ TEST $CLI_1 volume stop ${V0}_$i
|
|
|
14f8ab |
+ TEST $CLI_1 volume delete ${V0}_$i
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+done
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+for i in $(seq 1 6); do
|
|
|
14f8ab |
+ hostname="H$i"
|
|
|
14f8ab |
+ EXPECT_WITHIN $PROCESS_DOWN_TIMEOUT 0 check_shd ${!hostname}
|
|
|
14f8ab |
+done
|
|
|
14f8ab |
+cleanup
|
|
|
14f8ab |
diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
|
|
|
14f8ab |
index a9eab42..75f9a07 100644
|
|
|
14f8ab |
--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
|
|
|
14f8ab |
+++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
|
|
|
14f8ab |
@@ -254,14 +254,26 @@ glusterd_shdsvc_manager(glusterd_svc_t *svc, void *data, int flags)
|
|
|
14f8ab |
{
|
|
|
14f8ab |
int ret = -1;
|
|
|
14f8ab |
glusterd_volinfo_t *volinfo = NULL;
|
|
|
14f8ab |
+ glusterd_conf_t *conf = NULL;
|
|
|
14f8ab |
+ gf_boolean_t shd_restart = _gf_false;
|
|
|
14f8ab |
|
|
|
14f8ab |
+ conf = THIS->private;
|
|
|
14f8ab |
volinfo = data;
|
|
|
14f8ab |
+ GF_VALIDATE_OR_GOTO("glusterd", conf, out);
|
|
|
14f8ab |
GF_VALIDATE_OR_GOTO("glusterd", svc, out);
|
|
|
14f8ab |
GF_VALIDATE_OR_GOTO("glusterd", volinfo, out);
|
|
|
14f8ab |
|
|
|
14f8ab |
if (volinfo)
|
|
|
14f8ab |
glusterd_volinfo_ref(volinfo);
|
|
|
14f8ab |
|
|
|
14f8ab |
+ while (conf->restart_shd) {
|
|
|
14f8ab |
+ synclock_unlock(&conf->big_lock);
|
|
|
14f8ab |
+ sleep(2);
|
|
|
14f8ab |
+ synclock_lock(&conf->big_lock);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+ conf->restart_shd = _gf_true;
|
|
|
14f8ab |
+ shd_restart = _gf_true;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
ret = glusterd_shdsvc_create_volfile(volinfo);
|
|
|
14f8ab |
if (ret)
|
|
|
14f8ab |
goto out;
|
|
|
14f8ab |
@@ -310,6 +322,8 @@ glusterd_shdsvc_manager(glusterd_svc_t *svc, void *data, int flags)
|
|
|
14f8ab |
}
|
|
|
14f8ab |
}
|
|
|
14f8ab |
out:
|
|
|
14f8ab |
+ if (shd_restart)
|
|
|
14f8ab |
+ conf->restart_shd = _gf_false;
|
|
|
14f8ab |
if (volinfo)
|
|
|
14f8ab |
glusterd_volinfo_unref(volinfo);
|
|
|
14f8ab |
if (ret)
|
|
|
14f8ab |
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
|
|
|
14f8ab |
index c0973cb..6d7dd4a 100644
|
|
|
14f8ab |
--- a/xlators/mgmt/glusterd/src/glusterd.c
|
|
|
14f8ab |
+++ b/xlators/mgmt/glusterd/src/glusterd.c
|
|
|
14f8ab |
@@ -1819,6 +1819,7 @@ init(xlator_t *this)
|
|
|
14f8ab |
conf->rpc = rpc;
|
|
|
14f8ab |
conf->uds_rpc = uds_rpc;
|
|
|
14f8ab |
conf->gfs_mgmt = &gd_brick_prog;
|
|
|
14f8ab |
+ conf->restart_shd = _gf_false;
|
|
|
14f8ab |
this->private = conf;
|
|
|
14f8ab |
/* conf->workdir and conf->rundir are smaller than PATH_MAX; gcc's
|
|
|
14f8ab |
* snprintf checking will throw an error here if sprintf is used.
|
|
|
14f8ab |
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
|
|
|
14f8ab |
index bd9f509..2ea8560 100644
|
|
|
14f8ab |
--- a/xlators/mgmt/glusterd/src/glusterd.h
|
|
|
14f8ab |
+++ b/xlators/mgmt/glusterd/src/glusterd.h
|
|
|
14f8ab |
@@ -222,6 +222,9 @@ typedef struct {
|
|
|
14f8ab |
gf_atomic_t blockers;
|
|
|
14f8ab |
uint32_t mgmt_v3_lock_timeout;
|
|
|
14f8ab |
gf_boolean_t restart_bricks;
|
|
|
14f8ab |
+ gf_boolean_t restart_shd; /* This flag prevents running two shd manager
|
|
|
14f8ab |
+ simultaneously
|
|
|
14f8ab |
+ */
|
|
|
14f8ab |
pthread_mutex_t attach_lock; /* Lock can be per process or a common one */
|
|
|
14f8ab |
pthread_mutex_t volume_lock; /* We release the big_lock from lot of places
|
|
|
14f8ab |
which might lead the modification of volinfo
|
|
|
14f8ab |
--
|
|
|
14f8ab |
1.8.3.1
|
|
|
14f8ab |
|