Basically for a "transaction" we have five system phases/states:
1. Before the user commands the transaction
2. While the commanding user "thinks" the transaction is in progress
3. For the commanding user, the transaction has finished, but the data has not been written to disk.
4. The transaction is being written to disk
5. Transaction finished and committed to disk.
For ACID databases, state 3 and 4 are guaranteed by the DBMS never to occur. Other users see the old version in state 1-2 and the new version in state 5. In case of a system crash in state 1-2, the old version will remain.
For UNIX in general, the only guarantee we have is that in states 3-5, no user on the system will see the old version of the file. The state after a crash in state 2-4 is undefined.
The guarantees we would like to add is:
- In case of a system crash during state 2/3, the old version will be on disk.
- In case of a system crash during state 4, the old or new version will be on disk.
- If the application crashes/segfaults/gets killed etc during state 2, the old version will be on disk.
The things that are left open to allow for optimization are:
- What other users see during state 2
- Which version (old or new) is left on disk after a crash in state 4.