diff options
author | Aravinda VK <avishwan@redhat.com> | 2015-10-11 20:26:16 +0530 |
---|---|---|
committer | Venky Shankar <vshankar@redhat.com> | 2015-12-01 23:13:05 -0800 |
commit | 58539176e0152fdb09f093d0cdd1cfc7840a5a4f (patch) | |
tree | 62915d0c8f9067f4339d9b4cbc6cc93d05e71ec4 /geo-replication | |
parent | 1a88359040ef1c68bcbe86a01d13a996a8adbb27 (diff) |
geo-rep: Fix FD leak from Active Geo-rep worker
Active worker tries to acquire lock in each iteration. On every successfull
lock acqusition it was not closing previously opened lock fd.
To see the leak, get the PID of worker,
ps -ax | grep feedback-fd
watch ls /proc/$pid/fd
BUG: 1225567
Change-Id: Ic476c24c306e7ab372c5560fbb80ef39f4fb31af
Signed-off-by: Aravinda VK <avishwan@redhat.com>
Reviewed-on: http://review.gluster.org/12332
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Milind Changire <mchangir@redhat.com>
Reviewed-by: Saravanakumar Arumugam <sarumuga@redhat.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
(cherry picked from commit 42def948ac8e5d24278cb000cc8f8906b83a8592)
Reviewed-on: http://review.gluster.org/12650
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'geo-replication')
-rw-r--r-- | geo-replication/syncdaemon/gconf.py | 1 | ||||
-rw-r--r-- | geo-replication/syncdaemon/master.py | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/geo-replication/syncdaemon/gconf.py b/geo-replication/syncdaemon/gconf.py index 39a70a650b3..97395b41b06 100644 --- a/geo-replication/syncdaemon/gconf.py +++ b/geo-replication/syncdaemon/gconf.py @@ -27,5 +27,6 @@ class GConf(object): to PASSIVE as well mainly for debugging""" active_earlier = False passive_earlier = False + mgmt_lock_fd = None gconf = GConf() diff --git a/geo-replication/syncdaemon/master.py b/geo-replication/syncdaemon/master.py index 6ddbaf7f06e..b47ecb5a534 100644 --- a/geo-replication/syncdaemon/master.py +++ b/geo-replication/syncdaemon/master.py @@ -468,10 +468,25 @@ class GMasterCommon(object): raise try: fcntl.lockf(fd, fcntl.LOCK_EX | fcntl.LOCK_NB) + # Close the previously acquired lock so that + # fd will not leak. Reset fd to None + if gconf.mgmt_lock_fd: + os.close(gconf.mgmt_lock_fd) + gconf.mgmt_lock_fd = None + + # Save latest FD for future use + gconf.mgmt_lock_fd = fd except: ex = sys.exc_info()[1] if fd: os.close(fd) + + # When previously Active becomes Passive, Close the + # fd of previously acquired lock + if gconf.mgmt_lock_fd: + os.close(gconf.mgmt_lock_fd) + gconf.mgmt_lock_fd = None + if isinstance(ex, IOError) and ex.errno in (EACCES, EAGAIN): # cannot grab, it's taken if not gconf.passive_earlier: |