Fix possible race condition applying schemas

Found an instance where two of these fired too close together, and
caused a fatal error. Use a write lock, and then catch the schema.apply
function in case it fails anyways.
This commit is contained in:
2024-01-11 00:06:11 -05:00
parent 39ec427c42
commit a5763c9d25
2 changed files with 7 additions and 2 deletions

View File

@ -94,7 +94,10 @@ def validate_schema(logger, zkhandler):
# Validate our schema against the active version
if not zkhandler.schema.validate(zkhandler, logger):
logger.out("Found schema violations, applying", state="i")
zkhandler.schema.apply(zkhandler)
try:
zkhandler.schema.apply(zkhandler)
except Exception as e:
logger.out(f"Failed to apply schema updates: {e}", state="w")
else:
logger.out("Schema successfully validated", state="o")