Database Record Locking

Attention: This feature is in Early Adopter Product (EAP) release status. We will continue the development of additional features and provide additional interfaces via patch updates and future releases. Please contact Micro Focus SupportLine if you require further clarification.

When your data files are stored in a datastore, the type of record locking in effect can be controlled by the MFDBFH_RECORD_LOCKING environment variable.

By default (that is, when this variable is not explicitly set), record locking is under the control of the Micro Focus Database File Handler (MFDBFH), where record locks are maintained in a separate lock table. When using this locking mode, the behavior of record locking COBOL file operations closely follows the same behavior when using FileShare.

When MFDBFH_RECORD_LOCKING=database is in effect, MFDBFH uses the native record locking mechanism of the database engine to establish and test locks on the data file records directly. This does increase performance, but at the cost of the locking behavior not matching traditional COBOL record locking behavior exactly. For example, database locking may decide to acquire a lock against an entire page or table, in which case records may appear as locked even though they were not explicitly locked by the user application. Additional database-specific differences in behavior are listed below.

Microsoft SQL Server

  • A read of a record that is locked by another run unit should return the record data and the 9/68 (LOCKED) condition. In database locking mode using SQL Server, the data will be returned but the status will be 0/0 (SUCCESS) if the locked record has not yet been modified by the run unit that owns the lock. This is because SQL Server permits reads of locked records if those records have not yet been modified.
  • A COBOL read using the with wait clause will not wait if the record is locked by a different run unit, but that run unit has not yet modified the record. This is for the same reason as above.
  • The COBOL Unlock statement will not release a file's record locks. Record locks are only released at syncpoint.