You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(webapp): close back-fill-vs-promotion race on env-keyspace cache writes
Stamp the env hash with an `__owner_worker_id` field at promotion time;
the back-fill Lua script reads it and CAS-skips the env write if it
doesn't match the worker the back-filler resolved to.
Scenario the guard closes:
1. Resolver reads env cache, misses
2. Resolver reads PG: findCurrentWorker -> A, BWT for A -> A's data
3. [promotion to B fires, atomically replaces env hash + by-worker:B]
4. Resolver fires back-fill with workerId=A
-> env hash now stamped owner=B; A != B -> back-fill skips env write
-> by-worker:A still written (harmless; key contains workerId, dead worker)
The by-worker keyspace doesn't need a CAS check — the key itself
contains the workerId, so stale writes land in a dead worker's keyspace
and are never read.
Devin Review flagged this as a sub-millisecond race bounded by the 24h
env TTL. Cost to close it is one extra HGET inside the Lua call (atomic
with the HSET, no extra round trip) and one extra HSET on the promotion
write.
0 commit comments