PLAIN/TEXT — ISSUE 175/456 COMPUTER SCIENCE · FOUNDATION / DATA / REPLICA LAG · ~4 MIN READING DATE: 2027-03-25 ARCHIVE: https://plaintext.click/newsletter/ SUBJECT: How an app can keep your saved change visible How an app can keep your saved change visible ============================================= / START HERE You change a profile name, save it, then reopen the page and see the old name. A read asks a data store for information. Read-your-writes is a promise that your later reads will include your own successfully completed earlier changes. A replica is another computer holding a copy; it may not have applied a newly saved change when the next read reaches it. / WHY NOW The issue is not merely whether copies eventually agree. The practical question is whether the next page shown to the person who made the edit can be prevented from going backward. / THE IDEA Imagine one primary server accepts writes and copies their ordered changes to another server. The replica can serve many reads, but receiving a change and making it visible are separate steps. A write acknowledgement from the primary alone does not prove that this particular replica is ready to show it. One policy sends the user’s follow-up reads to the current primary. Another tracks the position of the completed write in the replication stream, then uses only a replica that has applied at least that far. The application must also start a suitable fresh read rather than reuse an older database snapshot. / THE FORMAL IDEA serve read when applied_position ≥ required_write_position - applied_position is how far a replica has replayed changes in one ordered stream. required_write_position identifies a point at or after this session’s completed write. - ≥ means at least as far. The numbers below are simplified sequence positions, not clock times; real systems may use a database-specific log location or token. / RUN THE TINY EXAMPLE Change one thing. Predict what happens. Your saved name change is included by position 125. A replica has applied only through 123. 123 < 125, so it cannot yet satisfy the session’s requirement; wait or use a suitable other server. The replica reaches 127: 127 ≥ 125, so a fresh read can include your change. Change only the required write position to 122: the original replica position 123 would already be sufficient. The gate follows actual progress, not a guessed delay such as always wait one second. A slow connection can make a fixed wait too short; a fast one can make it needless. Progress information answers the causal question directly. / SO WHAT? This session-specific guarantee does not promise everyone’s latest change worldwide. Another user may have written after your required position. A browser or application cache can still show an older screen even if the database selection is correct. The whole read path must preserve the intended guarantee. / ONE CAVEAT Replication positions must refer to the correct history, especially after failover, and waiting needs a deadline and fallback policy. Some synchronous replication modes confirm receipt or durable storage without confirming visibility; applied changes are the relevant milestone for this read guarantee. / KEEP THIS To keep a saved edit visible, route the next read to a view known to include that write, not simply to any available copy. / SOURCE TRAIL [1] PostgreSQL — Replication and remote-apply visibility https://www.postgresql.org/docs/18/warm-standby.html [2] PostgreSQL — Recovery and replay positions https://www.postgresql.org/docs/18/functions-admin.html NEXT: How a small strip can carry much of a wall’s heat --- HARD IDEAS. PLAIN TEXT. You are receiving this because you asked for one clear computer-science or physics idea each day. Unsubscribe: https://plaintext.click/unsubscribe View in browser: https://plaintext.click/newsletter/2027/03/2027-03-25-read-your-writes.html From: Plain/Text / Brickston Consulting · 30 N Gould St Ste N, Sheridan, WY 82801 US · knowledge@plaintext.click