Transaction states are the five distinct stages a database transaction passes through during its lifecycle, from the moment it starts running until it either saves permanently or cancels completely.
Common transaction states:
Active: The transaction starts in this initial state and stays here while executing read and write operations. If all steps finish without errors, it moves forward, if an error occurs, it drops to the failed state.
Partially Committed: The transaction enters this state right after executing its final operation. At this stage, the results exist only in temporary memory and have not yet been written permanently to disk.
Committed: Once temporary memory changes are safely written to permanent storage from the partially committed state, the transaction becomes committed. At this point, the changes are permanent and cannot be undone by a rollback.
Failed: The transaction moves here if a hardware crash, power outage, or rule violation during the active or partially committed phase. No further operations can proceed from this point.
Aborted: After reaching the failed state, the DBMS uses undo logs to roll back all changes made so far and enters the aborted state. Once aborted, the system either kills the transaction permanently or restarts it from scratch.
Terminated: It is the final stage of a database transaction's lifecycle, marking the point where the transaction has completely finished and exited the system.
Loading…