iTwinJs Error: Lock Not Held: error updating element: exclusive lock not held on element for update #31
-
Hello I work on developing the FutureOn - iTwin connector.
Can you help to provide more information on what could be causing this error? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
The connector version we are using is:
|
Beta Was this translation helpful? Give feedback.
-
The error is a result of using pessimistic concurrency and failing to obtain a lock on the element you're trying to modify, before trying to modify it. Is this a new problem? Did something change (dependency versions, your code, etc) before it began occurring? Was the physical partition you are attempting to update created by a previous run of your connector, or by something else? Presumably your connector creates some Subject, and then puts all of the models+elements it creates under that subject's hierarchy. You should be able to use iModelDb.locks.acquireLocks to exclusively lock your root subject, which implicitly locks everything underneath that subject too. |
Beta Was this translation helpful? Give feedback.
Hello @pmconne I have managed to track down the problem in my connector code which appears to be a timing problem acquiring the iModel lock.
So this can be closed.