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