From 16f42cdef539d5c63784f989af9ae877a94d72e7 Mon Sep 17 00:00:00 2001 From: Milind Changire Date: Fri, 29 Jan 2016 13:53:07 +0530 Subject: georep: avoid creating multiple entries with same gfid Problem: CREATE + RENAME changelogs replayed by geo-replication cause stale old-name entries with same gfid on slave nodes. A gfid is a unique key in the file-system and should not be assigned to multiple entries. Solution: Create entry on slave only if lstat(gfid) at aux-mount fails. This applies to files as well as directories. Change-Id: Ice3340f4ae1251c2dcef024a2388c4d33b5d4919 BUG: 1296208 Signed-off-by: Milind Changire Reviewed-on: http://review.gluster.org/13316 Smoke: Gluster Build System Reviewed-by: Kotresh HR Reviewed-by: Aravinda VK NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System (cherry picked from commit 87d93fac9fcc4b258b7eb432ac4151cdd043534f) Reviewed-on: http://review.gluster.org/13571 --- geo-replication/syncdaemon/resource.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'geo-replication') diff --git a/geo-replication/syncdaemon/resource.py b/geo-replication/syncdaemon/resource.py index c7fdbf37308..c26054ad9df 100644 --- a/geo-replication/syncdaemon/resource.py +++ b/geo-replication/syncdaemon/resource.py @@ -698,11 +698,19 @@ class Server(object): logging.warn("Failed to remove %s => %s/%s. %s" % (gfid, pg, bname, os.strerror(er))) elif op in ['CREATE', 'MKNOD']: - blob = entry_pack_reg( - gfid, bname, e['mode'], e['uid'], e['gid']) + slink = os.path.join(pfx, gfid) + st = lstat(slink) + # don't create multiple entries with same gfid + if isinstance(st, int): + blob = entry_pack_reg( + gfid, bname, e['mode'], e['uid'], e['gid']) elif op == 'MKDIR': - blob = entry_pack_mkdir( - gfid, bname, e['mode'], e['uid'], e['gid']) + slink = os.path.join(pfx, gfid) + st = lstat(slink) + # don't create multiple entries with same gfid + if isinstance(st, int): + blob = entry_pack_mkdir( + gfid, bname, e['mode'], e['uid'], e['gid']) elif op == 'LINK': slink = os.path.join(pfx, gfid) st = lstat(slink) -- cgit