Skip to content

fix(orders): return 412 instead of 500 when a concurrent reserve loses the SummitAttendee_Email_SummitID race - #647

Open
romanetar wants to merge 1 commit into
mainfrom
fix/reserve-order-duplicate-attendee-412
Open

romanetar wants to merge 1 commit into
mainfrom
fix/reserve-order-duplicate-attendee-412

Conversation

@romanetar

@romanetar romanetar commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

ref: https://app.clickup.com/t/86bcjffzg

Problem

ReserveOrderTask finds-or-creates the attendee by (summit, email) with no serialization. Parallel reserves from the same buyer lose the race on the root flush with 1062 Duplicate entry ... SummitAttendee_Email_SummitID and the API answered 500 (seen on OCP Global 2026, Oct 14: 201, 412, 500, 500 within ~450 ms).

Change

  • Catch UniqueConstraintViolationException around tx_service->transaction() in ReserveOrderTask::run, outside the closure (the violation is raised by the flush after it returns).
  • Only violations naming SummitAttendee_Email_SummitID become a ValidationException (412); any other index violation is rethrown unchanged.
  • Unit tests in tests/SummitOrderServiceTest.php for both cases. The translation test fails on main.

Verification

  • New tests pass; the translation test fails without the fix.
  • SummitOrderServiceTest (15 errors) and OAuth2SummitOrdersApiTest (3 errors) have the same failures before and after this change (e.g. "Can not delete ticket type ... has sold tickets" in teardown).
  • Not covered: end-to-end 412 over HTTP, Saga::abort check, optional integration test, AutoAssignPrePaidTicketTask.

…s the SummitAttendee_Email_SummitID race

ReserveOrderTask finds-or-creates the attendee by (summit, email) with no
serialization, so parallel reserves from the same buyer fail on the root
flush with a 1062 duplicate entry and the API answered 500.

Catch UniqueConstraintViolationException outside the transaction closure
(the flush happens after it returns), translate violations naming
SummitAttendee_Email_SummitID into a ValidationException and rethrow any
other index violation unchanged.
@github-actions

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/summit-api/openapi/pr-647/

This page is automatically updated on each push to this PR.

@coderabbitai

coderabbitai Bot commented Oct 19, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cc0671e9-c943-46de-904f-b278288da957
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant