|
|
74096c |
From a75bb15fbe64f14580c44b8a33314c8bbeffdede Mon Sep 17 00:00:00 2001
|
|
|
74096c |
From: Ravishankar N <ravishankar@redhat.com>
|
|
|
74096c |
Date: Thu, 4 Jun 2020 18:54:46 +0530
|
|
|
74096c |
Subject: [PATCH 406/449] afr: support split-brain CLI for replica 3
|
|
|
74096c |
|
|
|
74096c |
Patch in upstream master: https://review.gluster.org/#/c/glusterfs/+/23502/
|
|
|
74096c |
|
|
|
74096c |
Ever since we added quorum checks for lookups in afr via commit
|
|
|
74096c |
bd44d59741bb8c0f5d7a62c5b1094179dd0ce8a4, the split-brain resolution
|
|
|
74096c |
commands would not work for replica 3 because there would be no
|
|
|
74096c |
readables for the lookup fop.
|
|
|
74096c |
|
|
|
74096c |
The argument was that split-brains do not occur in replica 3 but we do
|
|
|
74096c |
see (data/metadata) split-brain cases once in a while which indicate that there are
|
|
|
74096c |
a few bugs/corner cases yet to be discovered and fixed.
|
|
|
74096c |
|
|
|
74096c |
Fortunately, commit 8016d51a3bbd410b0b927ed66be50a09574b7982 added
|
|
|
74096c |
GF_CLIENT_PID_GLFS_HEALD as the pid for all fops made by glfsheal. If we
|
|
|
74096c |
leverage this and allow lookups in afr when pid is GF_CLIENT_PID_GLFS_HEALD,
|
|
|
74096c |
split-brain resolution commands will work for replica 3 volumes too.
|
|
|
74096c |
|
|
|
74096c |
Likewise, the check is added in shard_lookup as well to permit resolving
|
|
|
74096c |
split-brains by specifying "/.shard/shard-file.xx" as the file name
|
|
|
74096c |
(which previously used to fail with EPERM).
|
|
|
74096c |
|
|
|
74096c |
BUG: 1759875
|
|
|
74096c |
Change-Id: I203735b909c7d30fc4faaf3ecd4f5b6b379ab266
|
|
|
74096c |
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
|
|
|
74096c |
Reviewed-on: https://code.engineering.redhat.com/gerrit/202375
|
|
|
74096c |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
74096c |
---
|
|
|
74096c |
.../replicate/bug-1756938-replica-3-sbrain-cli.t | 111 +++++++++++++++++++++
|
|
|
74096c |
xlators/cluster/afr/src/afr-common.c | 3 +-
|
|
|
74096c |
xlators/features/shard/src/shard.c | 3 +-
|
|
|
74096c |
3 files changed, 115 insertions(+), 2 deletions(-)
|
|
|
74096c |
create mode 100644 tests/bugs/replicate/bug-1756938-replica-3-sbrain-cli.t
|
|
|
74096c |
|
|
|
74096c |
diff --git a/tests/bugs/replicate/bug-1756938-replica-3-sbrain-cli.t b/tests/bugs/replicate/bug-1756938-replica-3-sbrain-cli.t
|
|
|
74096c |
new file mode 100644
|
|
|
74096c |
index 0000000..c1bdf34
|
|
|
74096c |
--- /dev/null
|
|
|
74096c |
+++ b/tests/bugs/replicate/bug-1756938-replica-3-sbrain-cli.t
|
|
|
74096c |
@@ -0,0 +1,111 @@
|
|
|
74096c |
+#!/bin/bash
|
|
|
74096c |
+
|
|
|
74096c |
+. $(dirname $0)/../../include.rc
|
|
|
74096c |
+. $(dirname $0)/../../volume.rc
|
|
|
74096c |
+. $(dirname $0)/../../afr.rc
|
|
|
74096c |
+
|
|
|
74096c |
+cleanup;
|
|
|
74096c |
+
|
|
|
74096c |
+TEST glusterd;
|
|
|
74096c |
+TEST pidof glusterd;
|
|
|
74096c |
+TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0,1,2}
|
|
|
74096c |
+TEST $CLI volume set $V0 features.shard enable
|
|
|
74096c |
+TEST $CLI volume set $V0 features.shard-block-size 4MB
|
|
|
74096c |
+
|
|
|
74096c |
+TEST $CLI volume start $V0
|
|
|
74096c |
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" brick_up_status $V0 $H0 $B0/${V0}0
|
|
|
74096c |
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" brick_up_status $V0 $H0 $B0/${V0}1
|
|
|
74096c |
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" brick_up_status $V0 $H0 $B0/${V0}2
|
|
|
74096c |
+TEST glusterfs --volfile-server=$H0 --volfile-id=/$V0 $M0
|
|
|
74096c |
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 0
|
|
|
74096c |
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 1
|
|
|
74096c |
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 2
|
|
|
74096c |
+
|
|
|
74096c |
+#Create split-brain by setting afr xattrs/gfids manually.
|
|
|
74096c |
+#file1 is non-sharded and will be in data split-brain.
|
|
|
74096c |
+#file2 will have one shard which will be in data split-brain.
|
|
|
74096c |
+#file3 will have one shard which will be in gfid split-brain.
|
|
|
74096c |
+#file4 will have one shard which will be in data & metadata split-brain.
|
|
|
74096c |
+TEST dd if=/dev/zero of=$M0/file1 bs=1024 count=1024 oflag=direct
|
|
|
74096c |
+TEST dd if=/dev/zero of=$M0/file2 bs=1M count=6 oflag=direct
|
|
|
74096c |
+TEST dd if=/dev/zero of=$M0/file3 bs=1M count=6 oflag=direct
|
|
|
74096c |
+TEST dd if=/dev/zero of=$M0/file4 bs=1M count=6 oflag=direct
|
|
|
74096c |
+EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
|
|
|
74096c |
+
|
|
|
74096c |
+#-------------------------------------------------------------------------------
|
|
|
74096c |
+TEST setfattr -n trusted.afr.$V0-client-1 -v 0x000000010000000000000000 $B0/${V0}0/file1
|
|
|
74096c |
+TEST setfattr -n trusted.afr.$V0-client-2 -v 0x000000010000000000000000 $B0/${V0}0/file1
|
|
|
74096c |
+TEST setfattr -n trusted.afr.$V0-client-0 -v 0x000000010000000000000000 $B0/${V0}1/file1
|
|
|
74096c |
+TEST setfattr -n trusted.afr.$V0-client-2 -v 0x000000010000000000000000 $B0/${V0}1/file1
|
|
|
74096c |
+TEST setfattr -n trusted.afr.$V0-client-0 -v 0x000000010000000000000000 $B0/${V0}2/file1
|
|
|
74096c |
+TEST setfattr -n trusted.afr.$V0-client-1 -v 0x000000010000000000000000 $B0/${V0}2/file1
|
|
|
74096c |
+
|
|
|
74096c |
+#-------------------------------------------------------------------------------
|
|
|
74096c |
+gfid_f2=$(gf_gfid_xattr_to_str $(gf_get_gfid_xattr $B0/${V0}0/file2))
|
|
|
74096c |
+TEST setfattr -n trusted.afr.$V0-client-1 -v 0x000000010000000000000000 $B0/${V0}0/.shard/$gfid_f2.1
|
|
|
74096c |
+TEST setfattr -n trusted.afr.$V0-client-2 -v 0x000000010000000000000000 $B0/${V0}0/.shard/$gfid_f2.1
|
|
|
74096c |
+TEST setfattr -n trusted.afr.$V0-client-0 -v 0x000000010000000000000000 $B0/${V0}1/.shard/$gfid_f2.1
|
|
|
74096c |
+TEST setfattr -n trusted.afr.$V0-client-2 -v 0x000000010000000000000000 $B0/${V0}1/.shard/$gfid_f2.1
|
|
|
74096c |
+TEST setfattr -n trusted.afr.$V0-client-0 -v 0x000000010000000000000000 $B0/${V0}2/.shard/$gfid_f2.1
|
|
|
74096c |
+TEST setfattr -n trusted.afr.$V0-client-1 -v 0x000000010000000000000000 $B0/${V0}2/.shard/$gfid_f2.1
|
|
|
74096c |
+
|
|
|
74096c |
+#-------------------------------------------------------------------------------
|
|
|
74096c |
+TESTS_EXPECTED_IN_LOOP=5
|
|
|
74096c |
+function assign_new_gfid {
|
|
|
74096c |
+ brickpath=$1
|
|
|
74096c |
+ filename=$2
|
|
|
74096c |
+ gfid=$(gf_gfid_xattr_to_str $(gf_get_gfid_xattr $brickpath/$filename))
|
|
|
74096c |
+ gfid_shard=$(gf_gfid_xattr_to_str $(gf_get_gfid_xattr $brickpath/.shard/$gfid.1))
|
|
|
74096c |
+
|
|
|
74096c |
+ TEST rm $brickpath/.glusterfs/${gfid_shard:0:2}/${gfid_shard:2:2}/$gfid_shard
|
|
|
74096c |
+ TEST setfattr -x trusted.gfid $brickpath/.shard/$gfid.1
|
|
|
74096c |
+ new_gfid=$(get_random_gfid)
|
|
|
74096c |
+ new_gfid_str=$(gf_gfid_xattr_to_str $new_gfid)
|
|
|
74096c |
+ TEST setfattr -n trusted.gfid -v $new_gfid $brickpath/.shard/$gfid.1
|
|
|
74096c |
+ TEST mkdir -p $brickpath/.glusterfs/${new_gfid_str:0:2}/${new_gfid_str:2:2}
|
|
|
74096c |
+ TEST ln $brickpath/.shard/$gfid.1 $brickpath/.glusterfs/${new_gfid_str:0:2}/${new_gfid_str:2:2}/$new_gfid_str
|
|
|
74096c |
+}
|
|
|
74096c |
+assign_new_gfid $B0/$V0"1" file3
|
|
|
74096c |
+assign_new_gfid $B0/$V0"2" file3
|
|
|
74096c |
+
|
|
|
74096c |
+#-------------------------------------------------------------------------------
|
|
|
74096c |
+gfid_f4=$(gf_gfid_xattr_to_str $(gf_get_gfid_xattr $B0/${V0}0/file4))
|
|
|
74096c |
+TEST setfattr -n trusted.afr.$V0-client-1 -v 0x000000010000000100000000 $B0/${V0}0/.shard/$gfid_f4.1
|
|
|
74096c |
+TEST setfattr -n trusted.afr.$V0-client-2 -v 0x000000010000000100000000 $B0/${V0}0/.shard/$gfid_f4.1
|
|
|
74096c |
+TEST setfattr -n trusted.afr.$V0-client-0 -v 0x000000010000000100000000 $B0/${V0}1/.shard/$gfid_f4.1
|
|
|
74096c |
+TEST setfattr -n trusted.afr.$V0-client-2 -v 0x000000010000000100000000 $B0/${V0}1/.shard/$gfid_f4.1
|
|
|
74096c |
+TEST setfattr -n trusted.afr.$V0-client-0 -v 0x000000010000000100000000 $B0/${V0}2/.shard/$gfid_f4.1
|
|
|
74096c |
+TEST setfattr -n trusted.afr.$V0-client-1 -v 0x000000010000000100000000 $B0/${V0}2/.shard/$gfid_f4.1
|
|
|
74096c |
+
|
|
|
74096c |
+#-------------------------------------------------------------------------------
|
|
|
74096c |
+#Add entry to xattrop dir on first brick and check for split-brain.
|
|
|
74096c |
+xattrop_dir0=$(afr_get_index_path $B0/$V0"0")
|
|
|
74096c |
+base_entry_b0=`ls $xattrop_dir0`
|
|
|
74096c |
+
|
|
|
74096c |
+gfid_f1=$(gf_gfid_xattr_to_str $(gf_get_gfid_xattr $B0/$V0"0"/file1))
|
|
|
74096c |
+TEST ln $xattrop_dir0/$base_entry_b0 $xattrop_dir0/$gfid_f1
|
|
|
74096c |
+
|
|
|
74096c |
+gfid_f2_shard1=$(gf_gfid_xattr_to_str $(gf_get_gfid_xattr $B0/$V0"0"/.shard/$gfid_f2.1))
|
|
|
74096c |
+TEST ln $xattrop_dir0/$base_entry_b0 $xattrop_dir0/$gfid_f2_shard1
|
|
|
74096c |
+
|
|
|
74096c |
+gfid_f3=$(gf_gfid_xattr_to_str $(gf_get_gfid_xattr $B0/${V0}0/file3))
|
|
|
74096c |
+gfid_f3_shard1=$(gf_gfid_xattr_to_str $(gf_get_gfid_xattr $B0/$V0"0"/.shard/$gfid_f3.1))
|
|
|
74096c |
+TEST ln $xattrop_dir0/$base_entry_b0 $xattrop_dir0/$gfid_f3_shard1
|
|
|
74096c |
+
|
|
|
74096c |
+gfid_f4_shard1=$(gf_gfid_xattr_to_str $(gf_get_gfid_xattr $B0/$V0"0"/.shard/$gfid_f4.1))
|
|
|
74096c |
+TEST ln $xattrop_dir0/$base_entry_b0 $xattrop_dir0/$gfid_f4_shard1
|
|
|
74096c |
+
|
|
|
74096c |
+#-------------------------------------------------------------------------------
|
|
|
74096c |
+#gfid split-brain won't show up in split-brain count.
|
|
|
74096c |
+EXPECT "3" afr_get_split_brain_count $V0
|
|
|
74096c |
+EXPECT_NOT "^0$" get_pending_heal_count $V0
|
|
|
74096c |
+
|
|
|
74096c |
+#Resolve split-brains
|
|
|
74096c |
+TEST $CLI volume heal $V0 split-brain source-brick $H0:$B0/${V0}1 /file1
|
|
|
74096c |
+GFIDSTR="gfid:$gfid_f2_shard1"
|
|
|
74096c |
+TEST $CLI volume heal $V0 split-brain source-brick $H0:$B0/${V0}1 $GFIDSTR
|
|
|
74096c |
+TEST $CLI volume heal $V0 split-brain source-brick $H0:$B0/${V0}1 /.shard/$gfid_f3.1
|
|
|
74096c |
+TEST $CLI volume heal $V0 split-brain source-brick $H0:$B0/${V0}1 /.shard/$gfid_f4.1
|
|
|
74096c |
+TEST $CLI volume heal $V0
|
|
|
74096c |
+EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count $V0
|
|
|
74096c |
+cleanup;
|
|
|
74096c |
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
|
|
|
74096c |
index eef7fd2..32127c6 100644
|
|
|
74096c |
--- a/xlators/cluster/afr/src/afr-common.c
|
|
|
74096c |
+++ b/xlators/cluster/afr/src/afr-common.c
|
|
|
74096c |
@@ -2250,7 +2250,8 @@ afr_attempt_readsubvol_set(call_frame_t *frame, xlator_t *this,
|
|
|
74096c |
if ((spb_choice >= 0) &&
|
|
|
74096c |
(AFR_COUNT(success_replies, child_count) == child_count)) {
|
|
|
74096c |
*read_subvol = spb_choice;
|
|
|
74096c |
- } else if (!priv->quorum_count) {
|
|
|
74096c |
+ } else if (!priv->quorum_count ||
|
|
|
74096c |
+ frame->root->pid == GF_CLIENT_PID_GLFS_HEAL) {
|
|
|
74096c |
*read_subvol = afr_first_up_child(frame, this);
|
|
|
74096c |
} else if (priv->quorum_count &&
|
|
|
74096c |
afr_has_quorum(data_readable, this, NULL)) {
|
|
|
74096c |
diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c
|
|
|
74096c |
index 2e2ef5d..16d557b 100644
|
|
|
74096c |
--- a/xlators/features/shard/src/shard.c
|
|
|
74096c |
+++ b/xlators/features/shard/src/shard.c
|
|
|
74096c |
@@ -1472,7 +1472,8 @@ int shard_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc,
|
|
|
74096c |
shard_local_t *local = NULL;
|
|
|
74096c |
|
|
|
74096c |
this->itable = loc->inode->table;
|
|
|
74096c |
- if (frame->root->pid != GF_CLIENT_PID_GSYNCD) {
|
|
|
74096c |
+ if ((frame->root->pid != GF_CLIENT_PID_GSYNCD) &&
|
|
|
74096c |
+ (frame->root->pid != GF_CLIENT_PID_GLFS_HEAL)) {
|
|
|
74096c |
SHARD_ENTRY_FOP_CHECK(loc, op_errno, err);
|
|
|
74096c |
}
|
|
|
74096c |
|
|
|
74096c |
--
|
|
|
74096c |
1.8.3.1
|
|
|
74096c |
|