Save, Delete or Commit has failed because lock "XXX" is not held

This is what I do when there is a problem with the Lock. Tipically, the error message is as follows:

Save, Delete or Commit has failed because lock "XXX" is not held

Set up the Tracer tool

Enable the Locking event in the Tracer settings.

Let's trace and investigate

The problem may be caused by one of the following events:

  1. The last "Acquired Lock" step
  2. The last "Release Lock" step

It may be that the lock is acquired with the "Release on commit" option. This could be problematic especially when there is a deliberate Commit between assignments.

The following is a typical series of events when this error occurs:

  1. The Lock is acquired for the work object but it will be released on the next Commit.
  2. A Commit happens, and the Lock is released.
  3. During the creation of the new assignment, Pega tries to make a Commit.
  4. Pega fails because we don't hold the Lock of the work object.

So, the problem may be the rule that acquires the Lock (event 1), or the rule that make the deliberate commit (event 2). It's up to you to decide which one is the problem.

An example

Download and install this component and execute the Work-Lesson-ParentCase case type. You will see the problem when transitioning from the child to the parent case.

Tracing this transition will give us the solution.

The last "Acquired Lock" step occurs during the execution of the Work-.pzUpdate activity.

The Work-.pzUpdated activity is an OOTB activity that is used in the "Update a Case" shape. I really need this shape because I need to update the parent case (it uses an optimistic locking). So this shape is not a problem.

The last "Release Lock" step occurs during the execution of the MyActivity activity. This is a custom activity, so I need to refactor this activity to not to commit.

    Reference:
  • https://collaborate.pega.com/question/error-save-delete-or-commit-has-failed-because-lock-not-held-case-resolving

Comments

Popular posts from this blog