Locking of VSAM records in recoverable files

Earlier, the prevention of transaction deadlocks in terms of the record locks acquired whenever records in a recoverable file are modified was explained. These locks are acquired by VSAM if the file is accessed in record-level sharing (RLS) mode, and by CICS® if not. The locks are held on behalf of the transaction doing the change until it issues a syncpoint request or terminates (at which time a syncpoint is automatically performed). For VSAM recoverable file processing, note the following:

Update locks and delete locks (non-RLS mode only)

The record locks referred to above are known as update locks, because they are acquired whenever a record is updated (modified). A further type of lock (a delete lock) may also be acquired by file control whenever a DELETE, WRITE, or WRITE MASSINSERT command is being performed for a recoverable KSDS or a recoverable path over a KSDS. A delete operation therefore may acquire two separate locks on the record being deleted.

The separate delete lock is needed because of the way file control does its write operations. Before executing a WRITE MASSINSERT command to a KSDS or RRDS, file control finds and locks the empty range into which the new record or records are to go. The empty range is locked by identifying the next existing record in the data set and acquiring its delete lock.

The empty range is locked to stop other requests simultaneously adding records into it. Moreover, the record defining the end of the empty range cannot be removed during the add operation. If another transaction issues a request to add records into the empty range or to delete the record at the end of the range, the delete lock makes the transaction wait until the WRITE or WRITE MASSINSERT command is complete. The record held with a delete lock may, however, be updated by another transaction during the write operation if it is in another CI.

Unlike an update lock, a delete lock is held only for the duration of a delete or write operation, or a sequence of WRITE MASSINSERT commands terminated by an UNLOCK command. A WRITE MASSINSERT command that adds records to the file into more than one empty range releases the previous delete lock as it moves into a new empty range.

The CICS enqueuing mechanism is only for updates and deletes and does not prevent a read request being satisfied before the next syncpoint. The integrity of a READ command in these circumstances is not guaranteed.

[[ Contents Previous Page | Next Page Index ]]