What happens internally when a user commits a transaction?
In the world of Oracle, the COMMIT command is a sacred moment. It is the point where a transaction transitions from "tentative" to "permanent."
To a user, a commit feels instantaneous. But internally, Oracle is performing a high-speed "handshake" between memory and disk to ensure that even if the building loses power one millisecond later, your data is safe.
Before we look at the steps, you must understand one rule: Oracle does not write data blocks to the Data Files during a commit.
When you type COMMIT; and hit enter, the following four things happen in rapid succession:
Oracle assigns a unique, ever-increasing number to your transaction called an SCN. Think of this as a precise timestamp. This SCN is the "official" mark that your transaction is now part of the database's history.
The Log Writer (LGWR) process immediately wakes up. It grabs all the redo entries for your transaction from the Redo Log Buffer (in RAM) and writes them to the Online Redo Log Files (on Disk).
Crucial Point: The user's session hangs (waits) until LGWR confirms the write to disk is complete. This is the only physical I/O that must happen for a commit to succeed.
During your transaction, you likely had "locks" on certain rows (preventing others from changing them).
The Undo Segments (which stored the "old" version of your data in case you wanted to ROLLBACK) are marked as inactive. Oracle doesn't delete them immediately, but it notes that the space can be reused by other transactions later.
Notice that the Database Writer (DBWn) hasn't done anything yet. The updated rows are still sitting in the Database Buffer Cache (RAM).
Eventually (seconds or minutes later), DBWn will lazily write those "dirty" blocks to the physical Data Files.
If the system crashes before DBWn writes: Don't worry! Upon restart, SMON will read the Redo Logs (written by LGWR at commit time) and "replay" your changes into the data files.
| Action | Process Involved | Location | Result |
| Log Flush | LGWR | Redo Log Files (Disk) | Durability: The change is now permanent. |
| SCN Assignment | Instance | Memory | Ordering: Defines the "point in time" for the change. |
| Lock Release | PMON/Session | Memory | Concurrency: Other users can now edit the rows. |
| Data Write | DBWn | Data Files (Disk) | Sync: Happens later (asynchronous). |
Interestingly, Oracle also performs a "cleanout" where it goes back to the data blocks in memory and clears the "lock" bits on the headers. If the data blocks were already pushed out of memory, the next user who reads them will perform a "delayed block cleanout."