Skip to main content

What happens if a transaction fails midway?

If a transaction fails midway, all of its changes get undone.

The database rolls back to the state it was in before the transaction started. This is atomicity in action, either everything runs, or nothing does.

For example: if you're transferring money and the connection drops mid-operation, the system won't debit part of the amount - the transfer simply won't happen.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.