Resolve a deadlock in write_receptor_config()

This commit is contained in:
Jeff Bradberry
2022-08-31 15:49:40 -04:00
parent 1b650d6927
commit ebd200380a

View File

@@ -652,21 +652,22 @@ def write_receptor_config():
with open(__RECEPTOR_CONF, 'w') as file: with open(__RECEPTOR_CONF, 'w') as file:
yaml.dump(receptor_config, file, default_flow_style=False) yaml.dump(receptor_config, file, default_flow_style=False)
receptor_ctl = get_receptor_ctl() # This needs to be outside of the lock because this function itself will acquire the lock.
receptor_ctl = get_receptor_ctl()
attempts = 10 attempts = 10
for backoff in range(1, attempts + 1): for backoff in range(1, attempts + 1):
try: try:
receptor_ctl.simple_command("reload") receptor_ctl.simple_command("reload")
break break
except ValueError: except ValueError:
logger.warning(f"Unable to reload Receptor configuration. {attempts-backoff} attempts left.") logger.warning(f"Unable to reload Receptor configuration. {attempts-backoff} attempts left.")
time.sleep(backoff) time.sleep(backoff)
else: else:
raise RuntimeError("Receptor reload failed") raise RuntimeError("Receptor reload failed")
links = InstanceLink.objects.filter(source=this_inst, target__in=instances, link_state=InstanceLink.States.ADDING) links = InstanceLink.objects.filter(source=this_inst, target__in=instances, link_state=InstanceLink.States.ADDING)
links.update(link_state=InstanceLink.States.ESTABLISHED) links.update(link_state=InstanceLink.States.ESTABLISHED)
@task() @task()