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