Resolve race condition between multiple log archivers

This commit is contained in:
Jake Moshenko 2017-04-24 13:37:25 -04:00
parent 8499612c4c
commit a159bd3e77
2 changed files with 26 additions and 14 deletions

View file

@ -248,3 +248,13 @@ def get_archivable_build():
return RepositoryBuild.get(id=found_id)
except RepositoryBuild.DoesNotExist:
return None
def mark_build_archived(build_uuid):
""" Mark a build as archived, and return True if we were the ones who actually
updated the row. """
return (RepositoryBuild
.update(logs_archived=True)
.where(RepositoryBuild.uuid == build_uuid,
RepositoryBuild.logs_archived == False)
.execute()) > 0