Skip to content

Conversation

@alimkhann
Copy link
Owner

  • Add SELECT FOR UPDATE to lock GeneratedRoadmap row during counter updates
  • Prevents race condition where concurrent rating submissions corrupt counters
  • Fixes issue where rating_count could be 1 when 2 ratings were actually submitted
  • Ensures accurate rating averages in UI

Without row locking, two users submitting ratings simultaneously could both read the same initial counters (e.g., 0) and each write back their own incremented values. The last commit would win, causing the first rating to be lost from the aggregated stats even though both roadmap_ratings rows were successfully inserted.

All 8 rating tests passing.

- Add SELECT FOR UPDATE to lock GeneratedRoadmap row during counter updates
- Prevents race condition where concurrent rating submissions corrupt counters
- Fixes issue where rating_count could be 1 when 2 ratings were actually submitted
- Ensures accurate rating averages in UI

Without row locking, two users submitting ratings simultaneously could both
read the same initial counters (e.g., 0) and each write back their own
incremented values. The last commit would win, causing the first rating
to be lost from the aggregated stats even though both roadmap_ratings
rows were successfully inserted.

All 8 rating tests passing.
@vercel
Copy link

vercel bot commented Nov 16, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
commitly-landing Ready Ready Preview Comment Nov 16, 2025 0:57am

@alimkhann alimkhann merged commit eacd74a into main Nov 16, 2025
5 checks passed
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.

2 participants