From 0c39ae4bb678c256ea20387b88507565cc38872d Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Tue, 10 Jan 2017 00:30:42 -0500 Subject: [PATCH 311/361] geo-rep: Handle directory sync failure as hard error If directory creation is failed, return immediately before further processing. Allowing it to further process will fail the entire directory tree syncing to slave. Hence master will log and raise exception if it's directory failure. Earlier, master used to log the failure and proceed. mainline: > BUG: 1411607 > Reviewed-on: http://review.gluster.org/16364 > Smoke: Gluster Build System > NetBSD-regression: NetBSD Build System > CentOS-regression: Gluster Build System > Reviewed-by: Aravinda VK (cherry picked from commit d1f84c77faeaa915cc57e0c13925cfe8bbe90ad6) BUG: 1425695 Change-Id: Iba2a8b5d3d0092e7a9c8a3c2cdf9e6e29c73ddf0 Signed-off-by: Kotresh HR Reviewed-on: https://code.engineering.redhat.com/gerrit/101291 Tested-by: Milind Changire Reviewed-by: Atin Mukherjee --- geo-replication/syncdaemon/resource.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/geo-replication/syncdaemon/resource.py b/geo-replication/syncdaemon/resource.py index 9c7a70a..be97b16 100644 --- a/geo-replication/syncdaemon/resource.py +++ b/geo-replication/syncdaemon/resource.py @@ -628,16 +628,19 @@ class Server(object): # We do this for failing fops on Slave # Master should be logging this if cmd_ret is None: - return + return False if cmd_ret == EEXIST: disk_gfid = cls.gfid_mnt(e['entry']) - if isinstance(disk_gfid, basestring): - if e['gfid'] != disk_gfid: - failures.append((e, cmd_ret, disk_gfid)) + if isinstance(disk_gfid, basestring) and e['gfid'] != disk_gfid: + failures.append((e, cmd_ret, disk_gfid)) + else: + return False else: failures.append((e, cmd_ret)) + return True + failures = [] def matching_disk_gfid(gfid, entry): @@ -807,7 +810,15 @@ class Server(object): [pg, 'glusterfs.gfid.newfile', blob], [EEXIST, ENOENT], [ESTALE, EINVAL]) - collect_failure(e, cmd_ret) + failed = collect_failure(e, cmd_ret) + + # If directory creation is failed, return immediately before + # further processing. Allowing it to further process will + # cause the entire directory tree to fail syncing to slave. + # Hence master will log and raise exception if it's + # directory failure. + if failed and op == 'MKDIR': + return failures # If UID/GID is different than zero that means we are trying # create Entry with different UID/GID. Create Entry with @@ -816,7 +827,7 @@ class Server(object): path = os.path.join(pfx, gfid) cmd_ret = errno_wrap(os.chown, [path, uid, gid], [ENOENT], [ESTALE, EINVAL]) - collect_failure(e, cmd_ret) + collect_failure(e, cmd_ret) return failures -- 1.8.3.1