Typical unit of recovery log records
A typical sequence of log records is written for an insert of one row through TSO.
The
following record types are included:
- Begin_UR
- The first request to change a database begins a unit of recovery. The log record of that event is identified by its log RBA. That same RBA serves as an ID for the entire unit of recovery (the URID). All records related to that unit have that RBA in their log record headers (LRH). For rapid backout, the records are also linked by a backward chain in the LRH.
- Undo/Redo
- Log records are written for each insertion, deletion, or update of a row. They register the changes to the stored data, but not the SQL statement that caused the change. Each record identifies one data or index page and its changes.
- End Phase 2 records
- The end of a UR is marked by log records that tell whether the UR was committed or rolled back, and whether Db2 has completed the work associated with it. If Db2 terminates before a UR has completed, it completes the work at the next restart.
| Type of record | Information recorded |
|---|---|
| 1. Begin_UR | Beginning of the unit of recovery. Includes the connection name, correlation name, authorization ID, plan name, and LUWID. |
| 2. Undo/Redo for data | Insertion of data. Includes the database ID (DBID), page set ID, page number, internal record identifier (RID), and the data inserted. |
| 3. Undo/Redo for Index | Insertion of index entry. Includes the DBID, index space object ID, page number, and index entry to be added. |
| 4. Begin Commit 1 | The beginning of the commit process. The application has requested a commit either explicitly (EXEC SQL COMMIT) or implicitly (for example, by ending the program). |
| 5. Phase 1-2 Transition | The agreement to commit in TSO. In CICS® and IMS, an End Phase 1 record notes that Db2 agrees to commit. If both parties agree, a Begin Phase 2 record is written; otherwise, a Begin Abort record is written, noting that the unit of recovery is to be rolled back. |
| 6. End Phase 2 | Completion of all work required for commit. |
Table 2 shows the log records for processing and rolling back an insertion.
| Type of record | Information recorded |
|---|---|
| 1. Begin_UR | Beginning of the unit of recovery. |
| 2. Undo/Redo for data | Insertion of data. Includes the database ID (DBID), page set ID, page number, internal record identifier, and the data inserted. |
| 3. Begin_Abort | Beginning of the rollback process. |
| 4. Compensation Redo/Undo | Backing-out of data. Includes the database ID (DBID), page set ID, page number, internal record ID (RID), and data to undo the previous change. |
| 5. End_Abort | End of the unit of recovery, with rollback complete. |