2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-01-17 13:13:18 +00:00

Fix security key initialization race condition

When initializing security key, a background thread may occur.  Sometimes,
the system would go to daemonize while that thread was still running, and
the whole system could exit.  Leading to incomplete write to globals as well
as leaving the daemon looking at the data copied over from pre-fork and
seeing the last state of that thread forever frozen.  Make sure the background
threads are fully done prior to exiting.
This commit is contained in:
Jarrod Johnson 2016-03-08 11:30:27 -05:00
parent 40007a6a07
commit b6546f923b
2 changed files with 8 additions and 1 deletions

View File

@ -1238,10 +1238,14 @@ class ConfigManager(object):
pass
@classmethod
def shutdown(cls):
def wait_for_sync(cls):
cls._bg_sync_to_file()
if cls._cfgwriter is not None:
cls._cfgwriter.join()
@classmethod
def shutdown(cls):
cls.wait_for_sync()
sys.exit(0)
@classmethod

View File

@ -145,6 +145,9 @@ def _initsecurity(config):
with open(keyfile, 'r') as keyhandle:
key = keyhandle.read()
configmanager.init_masterkey(key)
# We don't want to os._exit() until sync finishes from
# init above
configmanager.ConfigManager.wait_for_sync()
def run():