1

I understand transactions were developed to meet two requirements:

  1. Concurrent DB access
  2. Resilience to system failures

I understand how the concurrency issue is motivated; to overcome the database consistency problem.

However, I have a question: How do transactions help system resilience to failures?

2 Answers 2

2

If I understand your question, the "resilience to system failure" is handled by the server to ensure that the transaction either:

  1. Succeeds in committing the transaction.

Or:

  1. Ensures that a non-committed transaction rolls back to the previous state.

In other words, the transaction completes successfully or else (in a failure) all the in-flight changes are undone since the transaction is incomplete.

1

One common answer to this question is to examine how a bank transfer might work.

Transferring money from account A to account B will have at least two distinct processes:

Account A decreases total
Account B increases total

If the system were to fail after the first process completed, and each separate process committed the data, then account A would be decreased and account B wouldn't be increased. The money would be effectively "lost".

Wrapping this in a transaction means that both processes must succeed for the transaction to be committed. It is not possible for money to be "lost".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.