17b94a
From 6e15fca1621b06270983f57ac146f0f8e52f0797 Mon Sep 17 00:00:00 2001
17b94a
From: Mohit Agrawal <moagrawal@redhat.com>
17b94a
Date: Tue, 9 Jun 2020 15:38:12 +0530
17b94a
Subject: [PATCH 449/449] test: Test case brick-mux-validation-in-cluster.t is
17b94a
 failing on RHEL-8
17b94a
17b94a
Brick process are not properly attached on any cluster node while
17b94a
some volume options are changed on peer node and glusterd is down on
17b94a
that specific node.
17b94a
17b94a
Solution: At the time of restart glusterd it got a friend update request
17b94a
from a peer node if peer node having some changes on volume.If the brick
17b94a
process is started before received a friend update request in that case
17b94a
brick_mux behavior is not workingproperly. All bricks are attached to
17b94a
the same process even volumes options are not the same. To avoid the
17b94a
issue introduce an atomic flag volpeerupdate and update the value while
17b94a
glusterd has received a friend update request from peer for a specific
17b94a
volume.If volpeerupdate flag is 1 volume is started by
17b94a
glusterd_import_friend_volume synctask
17b94a
17b94a
> Change-Id: I4c026f1e7807ded249153670e6967a2be8d22cb7
17b94a
> Credit: Sanju Rakaonde <srakonde@redhat.com>
17b94a
> fixes: #1290
17b94a
> Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
17b94a
> (Reviewed on upstream link https://review.gluster.org/#/c/glusterfs/+/24540/)
17b94a
> (Cherry pick from commit 955bfd567329cf7fe63e9c3b89d333a55e5e9a20)
17b94a
17b94a
BUG: 1844359
17b94a
Change-Id: I4c026f1e7807ded249153670e6967a2be8d22cb7
17b94a
Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
17b94a
Reviewed-on: https://code.engineering.redhat.com/gerrit/202812
17b94a
Tested-by: Mohit Agrawal <moagrawa@redhat.com>
17b94a
Reviewed-by: Sanju Rakonde <srakonde@redhat.com>
17b94a
Tested-by: RHGS Build Bot <nigelb@redhat.com>
17b94a
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
17b94a
---
17b94a
 tests/bugs/glusterd/brick-mux-validation-in-cluster.t | 4 +---
17b94a
 xlators/mgmt/glusterd/src/glusterd-utils.c            | 7 +++++--
17b94a
 xlators/mgmt/glusterd/src/glusterd.h                  | 4 ++++
17b94a
 3 files changed, 10 insertions(+), 5 deletions(-)
17b94a
17b94a
diff --git a/tests/bugs/glusterd/brick-mux-validation-in-cluster.t b/tests/bugs/glusterd/brick-mux-validation-in-cluster.t
17b94a
index f088dbb..b6af487 100644
17b94a
--- a/tests/bugs/glusterd/brick-mux-validation-in-cluster.t
17b94a
+++ b/tests/bugs/glusterd/brick-mux-validation-in-cluster.t
17b94a
@@ -100,10 +100,8 @@ $CLI_2 volume set $V0 performance.readdir-ahead on
17b94a
 $CLI_2 volume set $V1 performance.readdir-ahead on
17b94a
 
17b94a
 TEST $glusterd_1;
17b94a
+EXPECT_WITHIN $PROBE_TIMEOUT 2 peer_count
17b94a
 
17b94a
-sleep 10
17b94a
-
17b94a
-EXPECT 4 count_brick_processes
17b94a
 EXPECT_WITHIN $PROCESS_UP_TIMEOUT 4 count_brick_pids
17b94a
 EXPECT_WITHIN $PROCESS_UP_TIMEOUT 0  count_N/A_brick_pids
17b94a
 
17b94a
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
17b94a
index 2eb2a76..6f904ae 100644
17b94a
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
17b94a
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
17b94a
@@ -3758,6 +3758,7 @@ glusterd_compare_friend_volume(dict_t *peer_data, int32_t count,
17b94a
                "Version of volume %s differ. local version = %d, "
17b94a
                "remote version = %d on peer %s",
17b94a
                volinfo->volname, volinfo->version, version, hostname);
17b94a
+        GF_ATOMIC_INIT(volinfo->volpeerupdate, 1);
17b94a
         *status = GLUSTERD_VOL_COMP_UPDATE_REQ;
17b94a
         goto out;
17b94a
     } else if (version < volinfo->version) {
17b94a
@@ -4784,7 +4785,8 @@ glusterd_volinfo_stop_stale_bricks(glusterd_volinfo_t *new_volinfo,
17b94a
          * or if it's part of the new volume and is pending a snap,
17b94a
          * then stop the brick process
17b94a
          */
17b94a
-        if (ret || (new_brickinfo->snap_status == -1)) {
17b94a
+        if (ret || (new_brickinfo->snap_status == -1) ||
17b94a
+            GF_ATOMIC_GET(old_volinfo->volpeerupdate)) {
17b94a
             /*TODO: may need to switch to 'atomic' flavour of
17b94a
              * brick_stop, once we make peer rpc program also
17b94a
              * synctask enabled*/
17b94a
@@ -6490,7 +6492,8 @@ glusterd_brick_start(glusterd_volinfo_t *volinfo,
17b94a
      * three different triggers for an attempt to start the brick process
17b94a
      * due to the quorum handling code in glusterd_friend_sm.
17b94a
      */
17b94a
-    if (brickinfo->status == GF_BRICK_STARTING || brickinfo->start_triggered) {
17b94a
+    if (brickinfo->status == GF_BRICK_STARTING || brickinfo->start_triggered ||
17b94a
+        GF_ATOMIC_GET(volinfo->volpeerupdate)) {
17b94a
         gf_msg_debug(this->name, 0,
17b94a
                      "brick %s is already in starting "
17b94a
                      "phase",
17b94a
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
17b94a
index 1c6c3b1..f739b5d 100644
17b94a
--- a/xlators/mgmt/glusterd/src/glusterd.h
17b94a
+++ b/xlators/mgmt/glusterd/src/glusterd.h
17b94a
@@ -523,6 +523,10 @@ struct glusterd_volinfo_ {
17b94a
     pthread_mutex_t store_volinfo_lock; /* acquire lock for
17b94a
                                          * updating the volinfo
17b94a
                                          */
17b94a
+    gf_atomic_t volpeerupdate;
17b94a
+    /* Flag to check about volume has received updates
17b94a
+       from peer
17b94a
+    */
17b94a
 };
17b94a
 
17b94a
 typedef enum gd_snap_status_ {
17b94a
-- 
17b94a
1.8.3.1
17b94a