Onboarding Step Completion Visible Only After Replica Lag
A user marks a step done, reloads the page, and sees it incomplete again. The write landed on the primary; the read came from a lagging replica.
This bug has a specific signature: a user completes a step, the UI confirms it, they refresh or switch tabs, and the step is unchecked again — only to reappear completed a few hundred milliseconds or a few seconds later with no action from them. Nothing is actually lost. The write succeeded. The read that failed to see it hit a database replica that had not caught up yet.
Why onboarding is especially exposed
Most parts of an app tolerate a little replication lag because users do not immediately re-read what they just wrote — they move on to something else. Onboarding checklists are the opposite case: completing a step is almost always followed immediately by a read, because the whole point of the UI is to show the user their own progress changing in real time. You built the exact interaction pattern that makes read-after-write consistency visible as a bug, even though the data layer is behaving exactly as designed.
Where the lag actually comes from
If your onboarding API scales reads across replicas — a common and reasonable choice once the step-completion table gets enough traffic to want it off the primary — every write still has to physically copy to each replica before a query there reflects it. That copy is not instant. The gap is usually milliseconds under normal load, but it is not zero, and it grows under replica load, network hiccups, or a replica that briefly fell behind during a deploy. A checklist with light traffic may never show the bug in testing and then show it in production the first week.
The fix is routing, not retrying
The naive fix — reload a few times until the step shows as complete — treats a consistency problem as a flakiness problem, and it degrades badly: under real lag it just means the user watches the step flicker for longer. The reliable fix is read-after-write routing: for a short window after a user writes to a specific row, route their own reads for that row to the primary (or to whichever replica their write landed on, if you can target it), and only fall back to the general-purpose replica pool once enough time has passed that lag is no longer a concern.
// pseudocode: route this user's reads for a few seconds after their own write
if (recentlyWroteStep(userId, stepKey, withinMs: 3000)) {
readFromPrimary();
} else {
readFromReplicaPool();
}This keeps the replica pool doing its job for every read that is not immediately chasing a write, which is the overwhelming majority of onboarding traffic, while removing the flicker exactly where it would otherwise show up. If your checklist is embedded via the widget API, check whether its step-fetch call is one you control the routing for, or one that goes through a generic read path shared with everything else — that distinction decides whether this fix is a backend change or a request you need to make upstream.
A cheaper partial fix: optimistic client state
If primary-routing is more infrastructure than your current setup supports, a smaller change removes most of the visible symptom without touching the database layer: once the write response confirms success, update the client's local state immediately and treat the server's next read as a reconciliation check rather than the source of truth for that one step. The user sees their own completion instantly and consistently; only a genuinely failed write (not a lagging read) would ever contradict it. This does not fix lag, it just stops lag from being visible to the one person whose own action caused it — which is the only person who was going to notice.
What to measure instead of guessing
We have no number for how often this shows up in a typical deployment — that depends entirely on your replica topology and traffic, and no industry figure would transfer. What you can measure directly: log the timestamp of each step write and the timestamp (plus replica identity, if your driver exposes it) of each subsequent read for the same (user, step) pair, and track the distribution of the gap. If reads routinely follow writes within your replication lag window, you have a reproducible case, not an intermittent one — and the fix above will show up as that distribution collapsing toward zero visible staleness.
Related reading
Replica lag is one specific case of a step appearing to complete itself without the user's action lining up with what they see — for the case where the delay comes from your own backend job scheduling rather than infrastructure, see marking a step done from an async background job. For the related client-side case of a step briefly showing the wrong state before the real data arrives, see avoiding a flash of wrong steps on first paint. You can see step completion update live in the preview.