Types of locking in Pega
In Pega PRPC (Pega Rules Process Commander), the two primary types of locking in pega mechanisms used to manage concurrent access to cases and work items are.
There are two types of locking in Pega.
1. Default: Lock will be acquired when the case is opened.
2. Optimistic: Lock will be acquired only when action is taken on the case.
The type of locking can be chosen under the setting tab for case type. By default, Locking Multiple Operators cannot open the case simultaneously.
In optimistic locking, multiple operators can open a case in parallel. They cannot submit at the same time.
1. Default (Pessimistic) Locking:
- Description: In default or pessimistic locking, a lock on the case or work item is acquired as soon as a user opens it for processing. This lock ensures that only one user can make changes at a time by preventing modifications from other users until it is released.
- Use Case: This type of locking is ideal in scenarios where it is essential to maintain data integrity and consistency, especially when there is a high likelihood of conflicts arising from concurrent updates by multiple users.
- Conflict Resolution: Since the case is locked as soon as it is opened, other users attempting to access the same case will receive a notification that the case is locked and cannot be modified until the lock is released. This approach simplifies conflict resolution as it inherently prevents concurrent modifications.
Key Features:
- Immediate Lock Acquisition: As soon as a user opens a case, the system acquires a lock, preventing others from making changes.
- Lock Duration: The lock remains in place until the user completes their task and submits the changes, or the lock times out.
- Lock Management: Administrators can configure lock timeout settings to avoid locks being held indefinitely in case of user inactivity or system issues.
2.Optimistic Locking:
Description:
In optimistic locking, the system does not acquire a lock on the case or work item when a user opens it. Instead, the system applies the lock only when the user attempts to save changes to the case. This allows multiple users to open and view the same case simultaneously.
Use Case:
This type of locking benefits environments with infrequent conflicts and enhances system performance by reducing lock duration. It is suitable for scenarios where users are mostly reading data rather than updating it.
Conflict Resolution:
If two users try to save changes to the same case at the same time, the system will detect the conflict. The system notifies the second user attempting to save that another user has updated the case. They will need to reload the case and reapply their changes if necessary.
Key Features:
- Deferred Lock Acquisition: Users can view and potentially edit cases without immediate locks, only locking at the point of data modification.
- Conflict Detection: The system checks for conflicts when changes are saved. The system triggers a conflict resolution process if another user modifies the data.
- Version Control: This often involves maintaining version numbers or timestamps to detect changes made by other users.
Work Object types of locking in Pega Locking Functional Algorithm:
- When an operator tries to edit a case, PRPC verifies whether any other operator is currently editing the same case or not.
- If yes, it displays a message saying that some other operator is editing it.
- If no, it allows the current operator to edit the case.
Work Object Locking Technical:
- When an operator Try to edit a case; PRPC verifies if there is a record in the table “PR_SYS_LOCKS.”.
- This option conveys the core message: finding the record and its locked state due to another user’s edit.
- “If no record exists, PRPC adds a record in PR_SYS_LOCKS, granting the lock to the current user.”
Note:
Acquiring a lock means inserting a record into the PR_SYS_LOCKS table.
Releasing lock means deleting the record from the PR_SYS_LOCKS table.
When an operator opens a work object, PRPC acquires a lock-on case. At the same time, when others try to open the case, it displays the message’. Operator1 is modifying the C case. This is default locking.
Conclusion
Both types of locking in Pega serve different purposes and are chosen accordingly. Based on the specific needs of the application and the nature of user interactions with cases and work items.
More topics on pega click here