When updates are written to databases

The DEDB terms UNDO and REDO are analogous to the DL/I full function terms BACKOUT and COMMIT respectively. However, although the processes that these terms refer to have the similar end results, the processes themselves differ.

The difference is in the stage at which updates are written to the database. This is shown in Figure 1.
Figure 1. When updates are written to databases
For DL/I databases, updates are made during the first phase of two-phase commit, the PREPARE phase. For DEDBs, updates are made during the second phase, the COMMIT phase. Between the two phases, the unit of recovery is indoubt.

This difference in timing of writing updates dictates the action taken during the second phase of two-phase commit.

For full function DL/I databases:
  • If the phase 2 action is COMMIT, no action is needed to commit updates because DL/I wrote them to the database during phase 1.
  • If phase 2 action is ABORT, a BACKOUT of the updates is required because DL/I wrote them to the database during phase 1.
For DEDBs:
  • If phase 2 action is COMMIT, the changes must be REDOne to the database because they have only been made in main storage. (They are written (committed) to the database on DASD by the output threads, which are generated by the IMS™ system generation parameter OTHREADS. See IMS: System definition or IMS: System definition for guidance on this parameter.)
  • If phase 2 action is ABORT, no changes have to be made to the database, because the changes are still in main storage, and can be UNDOne from there.
REDO is also used to refer to the action required for committed DEDBs during emergency restart of IMS. IMS can determine from the log that a COMMIT was initiated, but that phase 2 is not indicated as complete. In this case, DEDB updates must be REDOne. The two phases are:
  1. Phase 1, in which CICS® directs syncpoint preparation and asks whether or not the updates to DBCTL databases can be committed.
  2. Phase 2, in which CICS tells DBCTL that it must either COMMIT or ABORT the resources. (CICS can request an ABORT without first issuing a PREPARE request. That is, CICS can bypass the first phase of two-phase commit when an update is being backed out.)
Figure 2 shows two-phase commit and describes the activities taking place.
Figure 2. Two-phase commit
The notes below the figure have been included in this alternative text for clarity. At the beginning of phase 1, the PREPARE phase, CICS receives a syncpoint request. The syncpoint request can be EXEC CICS SYNCPOINT, a DL/I TERM call, or a CICS task termination. CICS begins phase 1, sending a PREPARE request via a task-related user exit (TRUE) interface to DBCTL. When DBCTL receives the PREPARE request, it enters phase 1, during which it writes to the log and retains locks. It then sends CICS a response to the PREPARE request. If DBCTL indicates at this stage that it cannot commit the updates, CICS aborts the unit of recovery and the rest of this process does not take place. From the point where DBCTL receives the PREPARE request, to the point where it sends a response to CICS, units of recovery are in-flight, and if DBCTL fails during this stage, all database updates are aborted.When CICS receives the response from DBCTL, it writes to the log, and then phase 1 ends. CICS begins phase 2, the COMMIT phase, by sending a COMMIT request to DBCTL. If CICS tells DBCTL to commit the updates, DBCTL must commit. From the time that DBCTL issues its response to the PREPARE request, to the time it receives a COMMIT request from CICS, units of recovery are indoubt. DBCTL retains the indoubt information. When DBCTL is restarted after a failure, it inquires with CICS about the status of the in-doubts. This is part of resynchronization.When DBCTL receives the COMMIT request, it enters phase 2, and the changes are committed. DBCTL writes to the log and releases locks. It then returns an OK message to CICS, and CICS writes an end-of-syncpoint record to the log. The process is now complete.
Note:
  1. The syncpoint request can be EXEC CICS SYNCPOINT, a DL/I TERM call, or a CICS task termination.
  2. If DBCTL indicates that it cannot commit the updates, CICS aborts the unit of recovery and the rest of the Figure 2 does not apply.
  3. If CICS tells DBCTL to commit the updates, DBCTL must commit.
  4. At this stage, units of recovery are in-flight and, if DBCTL fails, all database updates are aborted.
  5. At this stage, from the time that DBCTL issues its response to the PREPARE request to the time it receives a COMMIT request from CICS, units of recovery are indoubt. DBCTL retains the indoubt information. When DBCTL is restarted after a failure, it inquires with CICS about the status of the in-doubts. This is part of resynchronization.


dfht42o.html | Timestamp icon Last updated: Sunday, 4 June 2017