Pessimistic Locking
Overview
Documentation
Description
This project provides a simple solution for Pessimistic* Locking that stores record locks in the database and so will work for applications that have the potential of horizontal scalability.
The basic principle is to use the GUID of the object as the key for the lock record entity and apply a uniqueness constraint on the GUID. This prevents two locks being created for the same object, even if a second transaction commences before the first is committed.
Note that where two locks are requested simultaneously (before the first has committed), the second transaction will be blocked until the first has committed, so there could be a visible delay if you have long running microflows.
Typical usage scenario
It is important to prevent two users from editing the same entity instance at the same time. E.g. Sales Order, Employee, etc.
You want to avoid users losing work.
Features and limitations
The lock expiration period is governed by a constant. If a lock has expired another user can override it. A before-commit microflow is used to check that the user still has the lock at the time that they commit a transaction. The expiration period for the lock is reset each time the lock is confirmed, so that the expiration is a measure of inactivity rather than of how long the user has been working with a particular piece of information. Details are annotated within the model.
Dependencies [optional]
-
Community Commons module
-
Mendix Modeler V7 (see https://docs.mendix.com/refguide/uniqueness-constraint-migration)
Installation [optional]
The project is provided to demonstrate a way of achieving pessimistic locking. To install, export the “ObjectLocking” module and import it into your project. You will need to connect it to the objects you want to lock following the pattern in the example project.
It is important that you take full responsibility for testing that it meets your requirements.
Configuration [optional]
A constant is provided to set the lock timeout period. You may want to change various aspects of the locking behaviour to meet your specific business requirements.
Known bugs [optional]
Frequently Asked Questions [optional]
- Q:
- A: