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(run-store): keep caller replica reads on a replica; escalate only writer/tx
Review follow-up to the read-your-writes routing fix. The presence-only signal
(`client != null`) escalated EVERY caller-passed read client to the owning
store's primary, including an explicit read replica (e.g. `$replica`) passed by
span/trace/session lookups and the run-ops read-through — defeating replica
scaling.
Writer and replica Prisma clients are structurally identical at runtime (a
replica is a `new PrismaClient(...)` too, so it also exposes `$transaction`), so
shape can't tell them apart. The client builder now brands replica handles
(`markReadReplicaClient`) and the routing store reads the brand: a writer/tx
still escalates to the owning primary (read-your-writes, incl. the dequeue hot
path), while a branded replica or no client keeps the owning store's replica.
Also probe the PRIMARY in `forWaitpointCompletion`'s store-resolution (it selects
the store a subsequent write lands on), mirroring `#resolveWaitpointStore` — a
replica-lagged probe could mis-resolve the owner and strand the run.
Tests: branded-replica-stays-on-replica vs writer-escalates (routed reads); and
forWaitpointCompletion resolving the owner under replica lag. Seed the snapshot↔
waitpoint link via the Prisma relation API instead of a raw join-table insert.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments