Forcibly releasing/acquiring locks through JS API


(Joe) #1

When I try to call:

squizApi.acquireLock({
“asset_id”: “16812312”,
“screen_name”:“metadata”,
“force_acquire”: true
});

I always get

{ message: “Unable to acquire “metadata” lock on “A”, lock already held by “XXX” [SYS0101]”, time:1535407917, warning:true }

… if the user is not me.

Is there any way I can assure releasing or removing the locks on a specific asset?


(Bart Banda) #2

No, I don’t think you can “steal” someone else’s locks via the JS API. You can fire the https://matrix.squiz.net/manuals/web-services/chapters/javascript-api#releaseLock call to release the locks for your own user only.


(Joe) #3

Is there any way to get around someone’s locks?

We use JS API for a lot of large batch operations, such as applying metadata schemas, saving updated content, changing metadata fields etc. - but if any of the assets happen to have a lock on them, the operation will not apply to the ‘locked’ assets. Even worse, in some cases, we get a false-positive success response from the JS API (e.g. “Content has been updated…”, but it was not).

Of course, there’s no problem if the locks are owned by a user that’s performing the operations through JS API.

Would using a root user help?

Thanks a lot for help!


(Bart Banda) #4

Unfortunately, not without forcibly releasing that user’s locks first, which could lead to content loss quite easily as that user would lose their changes as soon as they try and hit save. Maybe do a check first for the assets you want to update using https://matrix.squiz.net/manuals/web-services/chapters/javascript-api#getLocksInfo and then proceed if nobody else has the locks?