3 ms·
If you were building a critical system, what would do if power is cut after the last line of a script runs?
by hermannj314 3y ago
If you were building a critical system, what would do if power is cut after the last line of a script runs?
- munk-a 3y agoIdempotency is usually the best approach - have each step of a process examine the state of the disk and act only if it's an appropriate input then output something that isn't an appropriate input. Assuming you can ignore midstream corruption (which can safely be done by adding an atomically safe linking layer on top) then if power suddenly cuts out reboot and run the script until a clause finds an appropriate input and executes it continuing from there. The concepts are simple, the implementation is a pain and (honestly) if you need something truly resilient you're probably better off leaning on a system that can provide that guarantee for you (like using a database for state storage).