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