Open3 months ago

Atomic vote counting via Postgres RPC (fix TOCTOU race)

The current vote endpoint reads vote_count then writes vote_count + 1 — a classic read-modify-write race. Under concurrent load two requests can both read the same number and both write the same increment, losing votes. Replace with a single atomic UPDATE feature_requests SET vote_count = vote_count + 1 WHERE id = $1 RETURNING vote_count called via an RPC.

Status: Open · Submitted May 18, 2026

Comments (0)

No comments yet.

Want to be notified when this ships? Sign in to follow this request.

Atomic vote counting via Postgres RPC (fix TOCTOU race) - Shpd