Commit d7aba34
committed
fix(tests): eliminate empty image-occurrence-set race in integration seeding
Address intermittent CI failures caused by concurrent creation of the shared empty image occurrence set.
Root cause:
- integration helpers seeded ImageOccurrenceSet via upsert on the same occurrencesHash from concurrent test flows
- under contention, Prisma intermittently surfaced P2002 unique-constraint errors, producing flaky API integration failures
Changes:
- add getOrCreateEmptyImageOccurrenceSet() in api-endpoints.integration.shared.ts
- replace direct imageOccurrenceSet upsert in ensurePostVersionForSeed() with the new helper
- add explicit unique-constraint handling (code P2002) and race recovery by reloading the raced row
- keep helper promise-cached per process for the shared empty occurrence-set row to reduce duplicate concurrent create attempts
- harden production-side createOrFindByUniqueConstraint in post.ts with bounded retry after unique-constraint races before rethrowing
Validation:
- pnpm typecheck passed
- pnpm lint:ci passed
- pnpm run test:integration:api passed
- stress check: pnpm run test:integration:api passed 5 consecutive times1 parent e9c8a1c commit d7aba34
2 files changed
Lines changed: 56 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
96 | 98 | | |
97 | 99 | | |
98 | 100 | | |
| |||
706 | 708 | | |
707 | 709 | | |
708 | 710 | | |
709 | | - | |
710 | | - | |
711 | | - | |
712 | | - | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
713 | 720 | | |
714 | | - | |
715 | | - | |
| 721 | + | |
716 | 722 | | |
717 | 723 | | |
718 | 724 | | |
| |||
Lines changed: 44 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
415 | 415 | | |
416 | 416 | | |
417 | 417 | | |
| 418 | + | |
418 | 419 | | |
419 | 420 | | |
420 | 421 | | |
421 | 422 | | |
422 | 423 | | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
423 | 466 | | |
424 | 467 | | |
425 | 468 | | |
| |||
444 | 487 | | |
445 | 488 | | |
446 | 489 | | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
| 490 | + | |
453 | 491 | | |
454 | 492 | | |
455 | 493 | | |
| |||
0 commit comments