Protocol
Stage the mutation before committing it
The safest write is often the one you can inspect before it becomes a write.
Before you use it
- Use when
- A bulk update can be computed in advance and a wrong write would be costly to reverse.
Keep this limit in mind
- Staging does not remove concurrency, authorization or downstream-trigger risks; account for changes that can occur between preview and commit.
An idea to explore.
Try this idea.
Inspect the example, try the idea in your situation, then check your next move.
Why it matters
Split the operation into two phases. First generate the proposed changes into a temporary or reviewable form. Validate counts, key fields, invariants and representative examples. Only then apply the verified mutation set. Keep the staged artifact tied to the exact source snapshot so a later apply does not silently target different input.
Steps
- Generate the candidate changes without applying them to the authoritative target.
- Validate the candidate set against explicit business and data invariants.
- Freeze or fingerprint the candidate set and its source snapshot.
- Apply only the reviewed candidate set, then verify the result.
An example
For a mass business-partner update, produce the exact keys and new values first, compare them with source data, then execute that fixed set.
Check your result
The team can inspect exactly what will change before the authoritative state is modified.
Save and practise this idea
My learning
Read. Recall. Repeat.
Save this idea and return to it on any device.
Keep exploring
Connected ideas
You are readingStage the mutation before committing it
Ideas that link here
These ideas link to this one. Check their conditions and limits before use.
Useful with this ideaWrite invariants before the migration
Evidence and sources
Google SRE describes two-phase mutation as storing proposed mutations temporarily, validating them, and applying them only after verification.
Two-phase mutation adds complexity and may not fit every storage system or transaction model.
Improve and Optimize Data Processing Pipelines · Idempotent and Two-Phase Mutations
All sources (1)
Edition and review
Version 0.1.0
No review details are supplied for this edition.