An update lock allows updates but is compatible with shared locks; that is, an update lock allows a single writer and multiple readers, because of transaction isolation.
The update lock has strength between a reserve and an exclusive lock. Whereas an exclusive lock blocks shared locks, an update lock allows updates but is compatible with shared locks; that is, an update lock allows a single writer and multiple readers, because of transaction isolation.
Update locks reduce locking contention in JADE systems; for example, bottlenecks involving persistent collections in systems with a large number of transactions.
The update lock allows an object to be updated but without blocking other processes obtaining shared locks. The process with an update lock can update the object. Other processes can acquire shared locks on the object, but they see the most-recent committed edition.
Update locks can be automatically enabled by using the
process.useUpdateLocks(true);
The automatic lock applied when an object is first updated is an update lock rather than an exclusive lock. Conversely, set the parameter to false to disable the use of the update locks.
Before the process commits the transaction, update locks are automatically upgraded to exclusive locks, by blocking all subsequent shared locks and then upgrading each update lock. (An update lock cannot be upgraded until all existing shared locks are released.)
When an update lock is being placed and the process already has a shared lock on the object, the shared lock is released before the update lock is requested. The release of the lock occurs despite the process being in transaction state. The lock is not released if the shared lock is of session duration. This prevents potential shared lock deadlocks, but allows the possibility of another process updating the object between the releasing of the shared lock and the acquiring of the update lock. If this happens, a continuable exception is raised.
If releasing the shared lock is going to be a problem for your application, the process can manually acquire the update lock before using the object; that is, before the shared lock would otherwise be acquired.