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