Locking Strategies

Locking means protecting one or more rows from being overwritten by other users while you are working with those rows. Working with rows can be defined as either the simple act of reading those rows from the database, or the act of modifying those rows after retrieving them and before storing, or the act of storing those modified rows. The state that initiates locking depends on the type of locking which has been applied or defined.

Uniface recognizes the following types of locking:

The type of locking applied depends on the defaults for your DBMS, the definition of the entity or entities in the application model, and the use of the /lock switch with the read instruction.

If an entity contains one or more variable-length fields, Uniface creates an overflow table or file. Occurrences in overflow tables or files are not usually locked.

How Uniface Causes Locking

If possible, Uniface makes the DBMS lock separate rows. In some circumstances, pages are locked. If this is not possible, Uniface forces the DBMS to lock an occurrence by comparing the occurrence in the component with the occurrence in the database and, if the occurrences are the same, by forcing a lock with a dummy write to the database. Comparing occurrences and attempting a dummy write to the database can be costly in performance in some cases. Uniface offers a more advanced way of handling this with the U_VERSION field.

Releasing Locks

Generally, a commit or rollback causes locks to be released. The end of a transaction in a DBMS which recognizes transactions also causes any outstanding locks to be released.