What happens when a COMMIT is issued?

When a COMMIT is issued in Oracle, it performs a series of important actions to make your transaction permanent, release resources, and notify other users that the changes are finalized.

What Happens When COMMIT is Issued

1. All Changes Become Permanent

  • All DML operations (INSERT, UPDATE, DELETE) performed in the current transaction are saved to the database permanently.
  • These changes are now durable (according to the "D" in ACID).

2. Changes Become Visible to Other Users

  • Any other users or sessions querying the database will now be able to see the committed changes.
  • Before COMMIT, those changes were only visible to your session.

3. Locks Are Released

  • All row-level or table-level locks acquired during the transaction are released.
  • This allows other sessions to access or modify the affected rows.

4. Savepoints Are Erased

  • Any SAVEPOINTs created during the transaction are cleared.
  • You can no longer roll back to them after the COMMIT.

5. Transaction Ends

  • The current transaction is closed.
  • A new transaction begins implicitly, so you're in a new, clean transactional state.

6. Redo Log Buffers Are Flushed to Disk

  • Oracle writes the redo information (used for recovery) from memory to the online redo logs.
  • This ensures the database can recover your changes in case of a crash.

7. Undo Information May Be Discarded Later

  • Oracle maintains undo data temporarily to support features like read consistency and flashback.
  • After a COMMIT, undo data may eventually be overwritten or reused, depending on undo retention settings.

Summary of Actions After COMMIT

Action

Description

๐Ÿ”’ Lock Release

All row/table locks are released

๐Ÿ‘€ Visibility

Changes become visible to other users

๐Ÿงพ Redo Log Flush

Redo log buffers are written to disk

๐Ÿ’พ Data Persistence

Changes are permanently stored

๐Ÿงน Savepoints

All savepoints are cleared

๐Ÿ”„ New Transaction

A new transaction begins implicitly

 

๐Ÿง  Behind the Scenes (Internals)

Oracle uses several background processes to manage this:

  • LGWR (Log Writer): Writes redo entries to disk.
  • DBWn (Database Writer): May eventually write dirty buffers to datafiles (not necessarily at commit).
  • SMON: Handles cleanup of completed transactions.

 

 

No comments:

Post a Comment