Question
· Jun 6, 2019

"Failed to acquire exclusive lock" on insert

I have a custom process that is parsing HL7 and inserting it into a table. Periodically the inserts fail with # due to error: ERROR #5803: Failed to acquire exclusive lock on instance of.... 

Traditional databases would wait until the lock is removed then do the insert, but cache fails. I'm sure it's my coding approach.

How can I work around this? A Try/Catch loop?

Thanks in advance.

Discussion (7)2
Log in or sign up to continue

normally there is no need for such "wrapper"

typically %Save() returns a %Status object and then it's up to you to analyze it in case there is an error.
In the situation described here, all you can do is just a retry. 
- it could be a Lock collision 
- or the LockTable is full.  
Instead of fiddling in system parameters requiring a restart, you just wait and retry. 

if you are curious how often this happens you may add a loop counter. for further decisions