Recoverable files

For VSAM or BDAM files designated as recoverable, the duration of the locking action is extended. For VSAM files, the extended locking is on the updated record only, not the whole control interval.

The extended period of locking is needed to avoid an update committed by one task being backed out by another. (Consider what could happen if the nonextended locking action shown in Figure 1 was used when updating a recoverable file. If task A abends just after task B has reached sync point and has thus committed its changes, the subsequent backout of task A returns the file to the state it was in at the beginning of task A, and task B's committed update is lost.)

To avoid this problem, whenever a transaction issues a command that changes a recoverable file (or reads from a recoverable file before update), CICS® automatically locks the updated record until the change is committed (that is, until the end of the unit of work). Thus in the preceding example, Task B would not be able to access the record until Task A had committed its change at the end of the unit of work. Hence, it becomes impossible for Task B's update to be lost by a backout of Task A. For files opened in non-RLS mode, CICS provides this locking using the enqueue domain. For files opened in RLS mode, SMSVSAM provides the locking, and the locks are released at the completion of the unit of work at the request of CICS.

The file control commands that invoke automatic locking in this way are:
  • READ (for UPDATE)
  • WRITE
  • DELETE
Note:
  1. Enqueuing as previously described can lead to transaction deadlock (see Possibility of transaction deadlock).
  2. The scope of locks varies according to the access method, the type of access, and who obtains the lock:
    • BDAM exclusive control applies to the physical block
    • Non-RLS VSAM exclusive control applies to the control interval
    • CICS locks for BDAM (with NOEXCTL specified) apply to the record only
    • CICS locks for non-RLS VSAM apply to the record only
    • SMSVSAM locks for RLS apply to the record only
  3. VSAM exclusive control . The CICS enqueuing action on recoverable files opened in non-RLS mode lasts until the end of the unit of work. When a transaction issues a READ UPDATE command, VSAM's exclusive control of the control interval containing the record is held only long enough for CICS to issue an ENQ on the record. CICS then notifies VSAM to release the exclusive control of the CI, and reacquires this only when the task issues a REWRITE (or UNLOCK, DELETE, or SYNCPOINT) command. Releasing the VSAM exclusive CI lock until the task is ready to rewrite the record minimizes the potential for transaction deadlock
  4. For recoverable files, do not use unique key alternate indexes to allocate unique resources (represented by the alternate key). If you do, backout can fail in the following set of circumstances:
    1. A task deletes or updates a record (through the base or another alternate index) and the alternate index key is changed.
    2. Before the end of the first task's unit of work, a second task inserts a new record with the original alternate index key, or changes an existing alternate index key to that of the original one.
    3. The first task fails and backout is attempted.
    The backout fails because a duplicate key is detected in the alternate index indicated by message DFHFC4701, with a failure code of X'F0'. There is no locking on the alternate index key to prevent the second task taking the key before the end of the first task's unit of work. If there is an application requirement for this operation, you should use the CICS enqueue mechanism to reserve the key until the end of the unit of work.
  5. To ensure that the data being read is up-to-date, the application program should:
    • For files accessed in non-RLS mode, issue a READ UPDATE command (rather than a simple READ), thus locking the data until the end of the unit of work
    • For files accessed in RLS mode, use the consistent read integrity option.


dfht2c00203.html | Timestamp icon Last updated: Monday, 5 June 2017