Blob Blame History Raw
From a9c27ff4deeddf68acd37efdba9788e3119d2d92 Mon Sep 17 00:00:00 2001
From: Kotresh HR <khiremat@redhat.com>
Date: Tue, 3 Jul 2018 06:53:04 -0400
Subject: [PATCH 681/685] geo-rep: Fix for EINVAL errors while syncing symlinks

geo-rep goes to faulty in the following scenario
failing to proceed further. It's the workload
involving symlink, rename and creation of non
symlink file with same name

1. touch /mastermnt/file1
2. ln -s "/mastermnt/file1" /mastermnt/symlink
3. mv /mastermnt/symlink /mastermnt/rn_symlink
4. mkdir /mastermnt/symlink

Fixed the same.

This is the partial logical backport of below patch which
addresses the EINVAL errors. Note that this patch is not
comparing gfid but the upstream patch does gfid comaprison
and other stuff.

Backport of:
  > Patch: https://review.gluster.org/#/c/18011/
  > BUG: 1432046
  > Signed-off-by: Kotresh HR <khiremat@redhat.com>
  > Change-Id: Iaa12d6f99de47b18e0650e7c4eb455f23f8390f2
  > Reviewed-by: Aravinda VK <avishwan@redhat.com>

BUG: 1590774
Change-Id: Ib89a12f9c957254442117260aa26af337dcac6d4
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/143031
Reviewed-by: Aravinda Vishwanathapura Krishna Murthy <avishwan@redhat.com>
Tested-by: RHGS Build Bot <nigelb@redhat.com>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 geo-replication/syncdaemon/master.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/geo-replication/syncdaemon/master.py b/geo-replication/syncdaemon/master.py
index 52537ff..b251d3a 100644
--- a/geo-replication/syncdaemon/master.py
+++ b/geo-replication/syncdaemon/master.py
@@ -892,6 +892,15 @@ class GMasterChangelogMixin(GMasterCommon):
                         entry_update()
                         entries.append(edct(ty, stat=st, entry=en, gfid=gfid))
                     elif ty == 'SYMLINK':
+                        # stat the name and check whether it's still symlink
+                        # or same named file/dir is created deleting the symlink
+                        st1 = lstat(en)
+                        if (isinstance(st1, int) or not
+                            stat.S_ISLNK(st1.st_mode)):
+                            logging.debug('file %s got purged in the interim'
+                                          % go)
+                            continue
+
                         rl = errno_wrap(os.readlink, [en], [ENOENT], [ESTALE])
                         if isinstance(rl, int):
                             continue
-- 
1.8.3.1