When working with database it is often essential to use transactions. Say for example that I want to transfer a certain amount of money from account A to account B. This involves two queries:
- decrease the money in account A
- increase it in account B.
In theory I can make the queries separately, but errors happen. So, to be sure, I can pack the two queries inside a transaction and be sure that either both operations end regularly or nothing has changed at all. No money disappears or is created.
The problem is that it seems to me that this only shifts the responsibility from me to the database vendor. Now it is up to the database to make both operations and be sure that either both are made or nothing has changed. And the database developers face the same problems that errors happen.
What techniques do database vendors use to ensure safety for transactions?
The ACID – Implementations page on wikipedia will get you started on write-ahead logging, shadow paging and multi-version concurrency control. Follow the links to find more.
Each DBMS vendor implements their own algorithms, often several different ones depending on the context, full ACID or relaxed requirements, distributed transaction consistency requirements etc…