From 704841d4f2c74a9c1f8f8c367440065ae4e51815 Mon Sep 17 00:00:00 2001 From: Alexander Olekhnovich Date: Wed, 10 Apr 2024 14:07:36 +0200 Subject: [PATCH] Fix a potential issue with race condition when reloading a config When SIGHUP is sent during `load_config` it's possible that `config_reload_pending` will be set to `False` (thus overwriting the `True` value, which was set in signal handler) and new reload won't happen. --- pglookout/pglookout.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pglookout/pglookout.py b/pglookout/pglookout.py index 5e92e80..7df42d2 100755 --- a/pglookout/pglookout.py +++ b/pglookout/pglookout.py @@ -859,8 +859,12 @@ def _get_check_interval(self) -> float: def main_loop(self): while self.running: if self.config_reload_pending: - self.load_config() self.config_reload_pending = False + try: + self.load_config() + except: + self.config_reload_pending = True + raise try: self._apply_latest_config_version() except Exception as ex: # pylint: disable=broad-except