Question
· Sep 22

Cache Locking - how to remove Cache lock from another process

Hello to all my fellow Cache Developers/Experts out there :)

The purpose of this post is to get input/feedback regarding an issue we are having with our Cache LIS web-based application not being able to remove locks that were taken under a separate process.

Here is the background of how the LIS does the locking and details about the issue:

-> our LIS web-based application sets records into a queue for doing locks and unlocks (the LIS runs under one process - guessing its the CSP server processes that process the broweser-to-backend requests) NOTE:  Our LIS is a web application, so in order for locks to be honored across all running user sessions, the LIS web-based application had to implement a web-based lock manager (this was a recommendation from InterSystems circa 2007/2008)

-> our application has a background job that runs to process records placed into the queue that has the lock/unlock requests (this background job is a separate standalone process that would do the physical LOCK + or LOCK - commands)

-> Overall, the lock manager process (as it is called) works really well.  But there are times when an unlock request is not able to be processed and we end up with an orphaned lock. When that happens, the users are not able to do any work with the associated database table/record(s) until the lock is released.  So our LIS web-based application has a feature to display which accessions (cases) are locked and allows the user to select one or more of the locked accessions and click a button [Remove Lock] to remove the lock.  This is the feature that is NOT working.   We are guessing that is because the LIS web-based application is running under one Cache process and the background job that takes out the LOCK + is running under a separate Cache process.  And we are guessing the LIS web-based application does not have the proper permissions to be able to remove a lock for another Cache process.  We are unsure what permissions would be needed by the LIS application default Cache account to be able to remove locks for another Cache process, such as the background job that takes out the locks.

Your input/feedback regarding this issue and recommendations for how to allow the LIS web-based application to remove the locks is appreciated.

Best Regards and GO TEAM!!

Product version: Ensemble 2017.1
Discussion (4)3
Log in or sign up to continue

To remove a Caché lock from another process, consider the following points:

  1. Lock Command Basics:

    • To release locks, use the LOCK -lockname command. This will release locks owned by the current process. If the process holds multiple locks of the same name, issuing the command removes one of them. Lock removal can also specify lock type if needed, such as LOCK -lockname#locktype [1][2].
  2. System-wide Lock Management:

    • Locks across processes can be managed using the system lock table. The InterSystems Management Portal provides tools to remove locks from specific processes:
      • Go to System Operation → Locks → Manage Locks.
      • You can select a process and click “Remove” or “Remove All Locks for Process.” Removing a lock requires WRITE permission from the executing process or user [2].
  3. Lock Permissions:

    • If your web-based application does not have the permission to remove locks established by another process, ensure that the account has WRITE permissions for lock removal tasks. Locks are logged during removal in the audit database, if logging is enabled [2].
  4. Troubleshooting and Cleanup:

    • Always consider implementing robust error handling, such as a system flag or tracked state, to ensure cleanup of locks when processes terminate unexpectedly. When all locks must be released, an argumentless LOCK command clears all locks for the current process or on process termination [2][3].
  5. Advanced Cleanup Methods:

    • If managing locks associated with complex scenarios like transactions or state tracking, encapsulate cleanup logic in objects or dedicated routines within a registered object class. This ensures consistency and avoids dangling locks [3].

Following these practices with proper tools and permissions should enable your application to remove locks from other processes effectively. [1][2][3]

Sources:

One additional note (that I thought of after seeing the DC AI Bot response):  The DC AI Bot explains that the lock can be "manually" released by logging into terminal window and forcing the lock.  And while that is true, the goal of my post is to allow our support team to be able to use our LIS web-based application to remove the locks and NOT have to waste time logging in to another piece of software to perform the task that should be able to be done via our LIS application.  And as you can imagine, there is a whole separate support process including creation/updating/assignment/etc... of a support ticket if the support team is unable to use the LIS application for certain pre-defined/verified workflows.  So it is not cost-effective to have to deal with support tickets every time an orphaned lock needs to be removed.   So please keep this item in mind when offering feedback/suggestions for how to allow the LIS web-based application to remove the lock for another Cache process.   Best Regards.

I would consider, replacing the lock + and lock - with setting/killing a (temporary) global, which can be mapped to IRISTEMP for better performance, and avoid journaling. It might be easy to implement such in parallel to the current lock mechanism (add those while keep the old in place) then migrate the management page in the application to loop on this global instead of the entries in lock table. The new approach can also have the timestamp for the lock and then have a function that will auto-retain locks (kill) based on a time interval.