Skip to content
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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion commcare_connect/opportunity/visit_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,18 @@ def _bulk_update_payments(opportunity: Opportunity, imported_data: Dataset) -> P
payment = Payment.objects.create(opportunity_access=access, amount=amount, amount_usd=amount_usd)
seen_users.add(username)
payment_ids.append(payment.pk)
update_work_payment_date(access)
process_work_payment_dates(users)
hemant10yadav marked this conversation as resolved.
Show resolved Hide resolved
missing_users = set(usernames) - seen_users
send_payment_notification.delay(opportunity.id, payment_ids)
return PaymentImportStatus(seen_users, missing_users)


def process_work_payment_dates(accesses: list):
with transaction.atomic():
for oa in accesses:
update_work_payment_date(oa)


def _cache_key(currency_code, date=None):
return [currency_code, date.toordinal() if date else None]

Expand Down
Loading