Joey@jyu.dev originally posted this. I thought it was interesting and decided to build on it with some super simple bash examples. This is a hilarious example of: “You are technically correct. The best kind of correct.” [1]
Atomicity
Operations are “all or nothing.” There are no partial writes, it’s either written and then discarded, or not written at all.
echo "this is" > /dev/null && echo "all" || echo "or nothing"
Consistency
The system transitions from one valid state to another. Whenever you run cat /dev/null it will always be empty. You can echo anything to it successfully, but the state will always be consistent (empty).
echo "foo" > /dev/null
cat /dev/null
echo "bar" > /dev/null
cat /dev/null
Isolation
Concurrent transactions don’t interfere with each other. We can use xargs to run two processes in parallel to echo to /dev/null and always consistently. The outputs will never conflict because nothing is stored.
echo -e "Hello\nWorld" | xargs -n1 -P2 bash -c 'echo "$0" > /dev/null'
cat /dev/null
Durability
Once a transaction is committed, it remains so, even after crashes. Even after rebooting the state remains the same as before the reboot, so it is durable.
echo "foo" > /dev/null
cat /dev/null
sudo reboot now
cat /dev/null
[1] The Futurama reference:
Photo by Tima Miroshnichenko: https://www.pexels.com/photo/woman-reading-a-book-between-archive-drawers-6549364/
