Merge "Bulk delete of stored delayed calls"

This commit is contained in:
Zuul 2019-07-29 15:47:20 +00:00 committed by Gerrit Code Review
commit c77eeb2d14
1 changed files with 10 additions and 14 deletions

View File

@ -300,20 +300,16 @@ class LegacyScheduler(sched_base.Scheduler):
:param db_calls: Delayed calls to delete from DB.
"""
try:
db_api.delete_delayed_calls(id={'in': [c.id for c in db_calls]})
except Exception as e:
LOG.error(
"Failed to delete all delayed calls [exception=%s]", e
)
with db_api.transaction():
for call in db_calls:
try:
db_api.delete_delayed_call(call.id)
except Exception as e:
LOG.error(
"Failed to delete delayed call [call=%s, "
"exception=%s]", call, e
)
# We have to re-raise any exception because the transaction
# would be already invalid anyway. If it's a deadlock then
# it will be handled.
raise e
# We have to re-raise any exception because the transaction
# would be already invalid anyway. If it's a deadlock then
# it will be handled.
raise e
LOG.debug("Scheduler deleted %s delayed calls.", len(db_calls))