|
|
14f8ab |
From f40570f2f784dc61edb061a4931dcfc16bf51e7e Mon Sep 17 00:00:00 2001
|
|
|
14f8ab |
From: Aravinda VK <avishwan@redhat.com>
|
|
|
14f8ab |
Date: Mon, 5 Aug 2019 19:00:21 +0530
|
|
|
14f8ab |
Subject: [PATCH 277/284] geo-rep: Fix Config Get Race
|
|
|
14f8ab |
|
|
|
14f8ab |
When two threads(sync jobs) in Geo-rep worker calls `gconf.get` and
|
|
|
14f8ab |
`gconf.getr`(realtime) at the sametime, `getr` resets the conf object
|
|
|
14f8ab |
and other one gets None. Thread Lock is introduced to fix the issue.
|
|
|
14f8ab |
|
|
|
14f8ab |
```
|
|
|
14f8ab |
File "/usr/libexec/glusterfs/python/syncdaemon/syncdutils.py",
|
|
|
14f8ab |
line 368, in twrap
|
|
|
14f8ab |
tf(*aargs)
|
|
|
14f8ab |
File "/usr/libexec/glusterfs/python/syncdaemon/master.py", line 1987,
|
|
|
14f8ab |
in syncjob
|
|
|
14f8ab |
po = self.sync_engine(pb, self.log_err)
|
|
|
14f8ab |
File "/usr/libexec/glusterfs/python/syncdaemon/resource.py",
|
|
|
14f8ab |
line 1444, in rsync
|
|
|
14f8ab |
rconf.ssh_ctl_args + \
|
|
|
14f8ab |
AttributeError: 'NoneType' object has no attribute 'split'
|
|
|
14f8ab |
```
|
|
|
14f8ab |
|
|
|
14f8ab |
Backport of:
|
|
|
14f8ab |
> Patch: https://review.gluster.org/#/c/glusterfs/+/23158/
|
|
|
14f8ab |
> Change-Id: I9c245e5c36338265354e158f5baa32b119eb2da5
|
|
|
14f8ab |
> Updates: bz#1737484
|
|
|
14f8ab |
> Signed-off-by: Aravinda VK <avishwan@redhat.com>
|
|
|
14f8ab |
|
|
|
14f8ab |
Change-Id: I9c245e5c36338265354e158f5baa32b119eb2da5
|
|
|
14f8ab |
BUG: 1729915
|
|
|
14f8ab |
Signed-off-by: Kotresh HR <khiremat@redhat.com>
|
|
|
14f8ab |
Reviewed-on: https://code.engineering.redhat.com/gerrit/178960
|
|
|
14f8ab |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
14f8ab |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
14f8ab |
---
|
|
|
14f8ab |
geo-replication/syncdaemon/gsyncdconfig.py | 27 +++++++++++++++++++++------
|
|
|
14f8ab |
1 file changed, 21 insertions(+), 6 deletions(-)
|
|
|
14f8ab |
|
|
|
14f8ab |
diff --git a/geo-replication/syncdaemon/gsyncdconfig.py b/geo-replication/syncdaemon/gsyncdconfig.py
|
|
|
14f8ab |
index 1fc451f..38f3594 100644
|
|
|
14f8ab |
--- a/geo-replication/syncdaemon/gsyncdconfig.py
|
|
|
14f8ab |
+++ b/geo-replication/syncdaemon/gsyncdconfig.py
|
|
|
14f8ab |
@@ -17,6 +17,7 @@ import os
|
|
|
14f8ab |
import shutil
|
|
|
14f8ab |
from string import Template
|
|
|
14f8ab |
from datetime import datetime
|
|
|
14f8ab |
+from threading import Lock
|
|
|
14f8ab |
|
|
|
14f8ab |
|
|
|
14f8ab |
# Global object which can be used in other modules
|
|
|
14f8ab |
@@ -35,6 +36,7 @@ class GconfInvalidValue(Exception):
|
|
|
14f8ab |
class Gconf(object):
|
|
|
14f8ab |
def __init__(self, default_conf_file, custom_conf_file=None,
|
|
|
14f8ab |
args={}, extra_tmpl_args={}, override_from_args=False):
|
|
|
14f8ab |
+ self.lock = Lock()
|
|
|
14f8ab |
self.default_conf_file = default_conf_file
|
|
|
14f8ab |
self.custom_conf_file = custom_conf_file
|
|
|
14f8ab |
self.tmp_conf_file = None
|
|
|
14f8ab |
@@ -163,6 +165,11 @@ class Gconf(object):
|
|
|
14f8ab |
if value is not None and not self._is_valid_value(name, value):
|
|
|
14f8ab |
raise GconfInvalidValue()
|
|
|
14f8ab |
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ def _load_with_lock(self):
|
|
|
14f8ab |
+ with self.lock:
|
|
|
14f8ab |
+ self._load()
|
|
|
14f8ab |
+
|
|
|
14f8ab |
def _load(self):
|
|
|
14f8ab |
self.gconf = {}
|
|
|
14f8ab |
self.template_conf = []
|
|
|
14f8ab |
@@ -230,12 +237,19 @@ class Gconf(object):
|
|
|
14f8ab |
self._tmpl_substitute()
|
|
|
14f8ab |
self._do_typecast()
|
|
|
14f8ab |
|
|
|
14f8ab |
- def reload(self):
|
|
|
14f8ab |
+ def reload(self, with_lock=True):
|
|
|
14f8ab |
if self._is_config_changed():
|
|
|
14f8ab |
- self._load()
|
|
|
14f8ab |
+ if with_lock:
|
|
|
14f8ab |
+ self._load_with_lock()
|
|
|
14f8ab |
+ else:
|
|
|
14f8ab |
+ self._load()
|
|
|
14f8ab |
|
|
|
14f8ab |
- def get(self, name, default_value=None):
|
|
|
14f8ab |
- return self.gconf.get(name, default_value)
|
|
|
14f8ab |
+ def get(self, name, default_value=None, with_lock=True):
|
|
|
14f8ab |
+ if with_lock:
|
|
|
14f8ab |
+ with self.lock:
|
|
|
14f8ab |
+ return self.gconf.get(name, default_value)
|
|
|
14f8ab |
+ else:
|
|
|
14f8ab |
+ return self.gconf.get(name, default_value)
|
|
|
14f8ab |
|
|
|
14f8ab |
def getall(self, show_defaults=False, show_non_configurable=False):
|
|
|
14f8ab |
cnf = {}
|
|
|
14f8ab |
@@ -276,8 +290,9 @@ class Gconf(object):
|
|
|
14f8ab |
return cnf
|
|
|
14f8ab |
|
|
|
14f8ab |
def getr(self, name, default_value=None):
|
|
|
14f8ab |
- self.reload()
|
|
|
14f8ab |
- return self.get(name, default_value)
|
|
|
14f8ab |
+ with self.lock:
|
|
|
14f8ab |
+ self.reload(with_lock=False)
|
|
|
14f8ab |
+ return self.get(name, default_value, with_lock=False)
|
|
|
14f8ab |
|
|
|
14f8ab |
def get_help(self, name=None):
|
|
|
14f8ab |
pass
|
|
|
14f8ab |
--
|
|
|
14f8ab |
1.8.3.1
|
|
|
14f8ab |
|