mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 02:11:11 -05:00
Merge pull request #1450 from GSA/notify-api-1430
fix notification insert retry logic
This commit is contained in:
@@ -346,15 +346,19 @@ def save_api_email_or_sms(self, encrypted_notification):
|
|||||||
status=notification["status"],
|
status=notification["status"],
|
||||||
document_download_count=notification["document_download_count"],
|
document_download_count=notification["document_download_count"],
|
||||||
)
|
)
|
||||||
|
# Only get here if save to the db was successful (i.e. first time)
|
||||||
provider_task.apply_async([notification["id"]], queue=q)
|
provider_task.apply_async([notification["id"]], queue=q)
|
||||||
current_app.logger.debug(
|
current_app.logger.debug(
|
||||||
f"{notification['notification_type']} {notification['id']} has been persisted and sent to delivery queue."
|
f"{notification['notification_type']} {notification['id']} has been persisted and sent to delivery queue."
|
||||||
)
|
)
|
||||||
|
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
current_app.logger.info(
|
current_app.logger.warning(
|
||||||
f"{notification['notification_type']} {notification['id']} already exists."
|
f"{notification['notification_type']} {notification['id']} already exists."
|
||||||
)
|
)
|
||||||
|
# If we don't have the return statement here, we will fall through and end
|
||||||
|
# up retrying because IntegrityError is a subclass of SQLAlchemyError
|
||||||
|
return
|
||||||
|
|
||||||
except SQLAlchemyError:
|
except SQLAlchemyError:
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user