Add more db retry on action db API

When too many actions and dependencies operated on db, sometimes
deadlock will happen. This patch add retry to some action db api.

Change-Id: I2ceabf7f837b792de380ecea94d30b3629862045
Closes-Bug: #1675601
This commit is contained in:
Ethan Lynn 2017-03-29 22:31:42 +08:00
parent 5a8de07bbd
commit c16ec58240
1 changed files with 6 additions and 0 deletions

View File

@ -1097,6 +1097,8 @@ def dependency_add(context, depended, dependent):
synchronize_session='fetch')
@oslo_db_api.wrap_db_retry(max_retries=3, retry_on_deadlock=True,
retry_interval=0.5, inc_retry_interval=True)
def action_mark_succeeded(context, action_id, timestamp):
with session_for_write() as session:
@ -1135,6 +1137,8 @@ def _mark_failed(session, action_id, timestamp, reason=None):
_mark_failed(session, d, timestamp)
@oslo_db_api.wrap_db_retry(max_retries=3, retry_on_deadlock=True,
retry_interval=0.5, inc_retry_interval=True)
def action_mark_failed(context, action_id, timestamp, reason=None):
with session_for_write() as session:
_mark_failed(session, action_id, timestamp, reason)
@ -1160,6 +1164,8 @@ def _mark_cancelled(session, action_id, timestamp, reason=None):
_mark_cancelled(session, d, timestamp)
@oslo_db_api.wrap_db_retry(max_retries=3, retry_on_deadlock=True,
retry_interval=0.5, inc_retry_interval=True)
def action_mark_cancelled(context, action_id, timestamp, reason=None):
with session_for_write() as session:
_mark_cancelled(session, action_id, timestamp, reason)