summaryrefslogtreecommitdiffstats
path: root/geo-replication/syncdaemon/gsyncdstatus.py
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2018-08-10 08:14:14 -0400
committerAmar Tumballi <amarts@redhat.com>2018-08-13 03:52:07 +0000
commit0250d32f759dc553e28eca85fa3c18e7c22fd8f0 (patch)
tree302038739f41d5f88505071965aef2f0719b32de /geo-replication/syncdaemon/gsyncdstatus.py
parent29d5557854703f61a4aa1fc53d6b49de9a99fe9d (diff)
geo-rep: Fix deadlock during worker start
Analysis: Monitor process spawns monitor threads (one per brick). Each monitor thread, forks worker and agent processes. Each monitor thread, while intializing, updates the monitor status file. It is synchronized using flock. The race is that, some thread can fork worker while other thread opened the status file resulting in holding the reference of fd in worker process. Cause: flock gets unlocked either by specifically unlocking it or by closing all duplicate fds referring to the file. The code was relying on fd close, hence a reference in worker/agent process by fork could cause the deadlock. Fix: 1. flock is unlocked specifically. 2. Also made sure to update status file in approriate places so that the reference is not leaked to worker/agent process. With this fix, both the deadlock and possible fd leaks is solved. fixes: bz#1614799 Change-Id: I0d1ce93072dab07d0dbcc7e779287368cd9f093d Signed-off-by: Kotresh HR <khiremat@redhat.com>
Diffstat (limited to 'geo-replication/syncdaemon/gsyncdstatus.py')
-rw-r--r--geo-replication/syncdaemon/gsyncdstatus.py1
1 files changed, 1 insertions, 0 deletions
diff --git a/geo-replication/syncdaemon/gsyncdstatus.py b/geo-replication/syncdaemon/gsyncdstatus.py
index e8a810f4b38..87fa09c070c 100644
--- a/geo-replication/syncdaemon/gsyncdstatus.py
+++ b/geo-replication/syncdaemon/gsyncdstatus.py
@@ -103,6 +103,7 @@ class LockedOpen(object):
return f
def __exit__(self, _exc_type, _exc_value, _traceback):
+ fcntl.flock(self.fileobj, fcntl.LOCK_UN)
self.fileobj.close()