-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deadlock Detected in bulk update payments. #433
base: main
Are you sure you want to change the base?
Conversation
How does this address the issue? If wrapping the whole thing in a transaction does not prevent locks, why would a second nested transaction? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pending the answer to my question on lock timeout, looks good
payment_ids.append(payment.pk) | ||
update_work_payment_date(access) | ||
lock_key = f"bulk_update_payments_opportunity_{opportunity.id}" | ||
with cache.lock(lock_key, timeout=300): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How confident are you this timeout is long enough? I would have guessed some of the really big ones, might exceed this, or at least come close.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recently faced this. I think we can aim for around 10 minutes that should be sufficient, I guess.
CCCT-549
Sentry link
transaction.atomic()
block only ensures atomicity within a single Celery task, but does not prevent deadlocks between multiple concurrent tasks.To resolve this, I have used cache lock so that only one bulk update payment is allowed at a time.