Production engineering
using System;
using System.Linq;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
int current=10; int snapshot=current; current=20; Console.WriteLine("snapshot:"+snapshot); Console.WriteLine("fresh:"+current); current++; Console.WriteLine("replayed:"+current);
Reveal answer and reasoning
The console begins with current ten and copies it into snapshot. Changing current to twenty leaves the copied snapshot at ten, so the first two lines are snapshot:10 and fresh:20. Incrementing the fresh value prints replayed:21. Nothing in these variables is a database transaction, and the program does not establish that concurrent readers on another engine behave this way. It gives a deterministic example of the difference between repeating a decision based on ten and recomputing it from twenty.
That distinction is the domain fact the actual SQL retry experiment must preserve.
The real snapshot endpoint resets its owned counter to ten, opens a deferred reader and reads ten. Another connection commits twenty; the original transaction still reads ten, while a fresh connection reads twenty. The stale-write endpoint then records an actual busy error when that old read tries to upgrade into a writer, rolls back and starts a new transaction. Its fresh read sees twenty and writes twenty-one.
The final observation includes actual provider error codes, two unit attempts and the new value. Those codes are evidence for this provider fixture rather than a universal database exception taxonomy.
What a strong answer covers
- The portable program prints snapshot10, fresh20 and replayed21.
- The actual WAL reader and fresh connection observe different committed snapshots.
- A safe retry starts a fresh unit and repeats its dependent reads; it does not imply remote rollback.
Common pitfall
Retrying only the failed UPDATE while retaining a stale decision or repeating an external effect.
Follow-up questions
- Which transaction modes or providers would require different isolation evidence?
- What changes if the unit also sends a remote message before committing?
Self-review
Choose what to revisit. These marks are your own assessment and are separate from lesson completion.