Retry _trait_sync on deadlock

We're seeing DBDeadlock failures during scheduling in CI jobs
when syncing traits when getting allocation candidates.

We have a lock around this code but that's not going to carry across
multiple processes, so we need to be able to retry on deadlock if
one occurs.

Change-Id: I6cf1793c1cbed18d850ec7e32b5b195e78cb4e68
Closes-Bug: #1738083
This commit is contained in:
Matt Riedemann
2017-12-13 21:22:32 -05:00
parent e599b13e49
commit c66ae65775

View File

@@ -73,6 +73,7 @@ def _ensure_rc_cache(ctx):
_RC_CACHE = rc_cache.ResourceClassCache(ctx)
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@db_api.api_context_manager.writer
def _trait_sync(ctx):
"""Sync the os_traits symbols to the database.