Conversation
…or in Texas imports (#7145) Two fixes for errors encountered during Texas docket merging: 1. Add None check for workload transfer origin court ID in merge_texas_case_transfers. When texas_js_court_id_to_court_id returns None for unknown courts, skip the workload transfer with a warning instead of passing None to Court.objects.get(). 2. Wrap AttorneyOrganization.objects.create() in a savepoint in add_attorney. The enclosing add_parties_and_attorneys is @transaction.atomic, so an IntegrityError from a race condition on create() would abort the transaction. The recovery get() then failed with TransactionManagementError. The savepoint ensures only it rolls back, not the outer transaction. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Returned |
| with transaction.atomic(): | ||
| org = AttorneyOrganization.objects.create( | ||
| **atty_org_info | ||
| ) |
There was a problem hiding this comment.
This is my understanding of the fix. Looks good to me.
sequenceDiagram
participant P1 as Process 1
participant DB as PostgreSQL
participant P2 as Process 2
P1->>DB: BEGIN (add_parties_and_attorneys @transaction.atomic)
P1->>DB: AttorneyOrganization.objects.get(lookup_key="X")
DB-->>P1: DoesNotExist
Note over P2: Enter Villain
P2->>DB: AttorneyOrganization.objects.create(lookup_key="X")
DB-->>P2: OK ✓
P1->>DB: SAVEPOINT (with transaction.atomic) ← fix
P1->>DB: AttorneyOrganization.objects.create(lookup_key="X")
DB-->>P1: IntegrityError (duplicate key)
P1->>DB: ROLLBACK TO SAVEPOINT ← only savepoint is aborted
Note over P1: Catches IntegrityError, retries get()
P1->>DB: AttorneyOrganization.objects.get(lookup_key="X")
DB-->>P1: OK ✓
P1->>DB: COMMIT
|
Though it conjures hilarious images of gluttony to see |
albertisfu
left a comment
There was a problem hiding this comment.
This looks good. Merging!
Thank you.
Two fixes for errors encountered during Texas docket merging (see #7145):
Add None check for workload transfer origin court ID in merge_texas_case_transfers. When texas_js_court_id_to_court_id returns None for unknown courts, skip the workload transfer with a warning instead of passing None to Court.objects.get().
Wrap AttorneyOrganization.objects.create() in a savepoint in add_attorney. The enclosing add_parties_and_attorneys is @transaction.atomic, so an IntegrityError from a race condition on create() would abort the transaction. The recovery get() then failed with TransactionManagementError. The savepoint ensures only it rolls back, not the outer transaction.
Once all fixes have been added, I'll move this PR out of draft.
Deployment
This PR should:
skip-deploy(skips everything below)skip-web-deployskip-celery-deployskip-cronjob-deployskip-daemon-deploy