Commit a182209
authored
fix: add unique constraint on conference to prevent duplicate split (#21)
* fix: add unique constraint on conference (conference_id, app) to prevent duplicates
When two participants join the same session simultaneously, both call
POST /v1/initialize with the same conferenceId. Without a unique
constraint, both get_or_create calls create separate conference records
(race condition). This splits participants across different conference
pages.
Fix:
- Migration 0002: merges existing duplicates (keeps oldest, moves all
related events/sessions/connections/issues to it)
- Migration 0003: adds unique_together on (conference_id, app)
After this, concurrent get_or_create calls will correctly find the
existing conference instead of creating duplicates.
* fix: address review feedback on conference unique constraint migration
- Moved imports to top of file/function
- Wrapped each duplicate group in transaction.atomic()
- Added Summary model to reassignment (OneToOne FK to Conference)
- Added safety check on dup.delete() to catch unexpected cascades
* fix: address P1 and P2 review feedback on migration
P1: Removed over-strict cascade-delete guard. Deleting a duplicate
conference normally cascades to M2M join table rows (participant
through table), which is expected. The guard was raising on this.
P2: Replaced hasattr(keeper, 'summary') with a local boolean flag
(keeper_has_summary) that updates after the first summary is moved.
Avoids stale cached reverse OneToOne lookups across iterations.1 parent b5ad74e commit a182209
3 files changed
Lines changed: 83 additions & 0 deletions
File tree
- app
- migrations
- models
Lines changed: 65 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
0 commit comments