fix(webapp): two quick votes on the same slot no longer race into a 500 (#844) #847
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/vote-race-and-start-commit"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #844.
The bug:
vote_service.upsert_voteread the existing vote, then inserted or updated. TwoPUT …/timeslots/{id}/voterequests for the same slot and user could both see no row. The second insert then hituq_votes_slot_useras an IntegrityError, which came back as a 500.The fix: one
postgresql.insert(Vote).on_conflict_do_update(constraint="uq_votes_slot_user", …), the same pattern asnotification_settings_serviceand the transcript-feedback endpoint. It re-reads withpopulate_existing, and the router's side effects are unchanged.Tests:
test_votes.py::test_two_concurrent_votes_for_the_same_slot_and_user_both_succeedruns two real sessions on separate connections. It failed before the fix with the exact IntegrityError.Also (#845, investigated, no code change):
start_by_recordingalready commits before the response. A new two-connection regression test proves a fresh reader seesin_progressstraight away. #845 stays open, since the one J4 observation has another cause.🤖 Generated with Claude Code