Problem in locking a document using xdmp:lock-acquire() function

141 views Asked by At

We have tried all the options for the lock method, the document is locked, but still, another user can able to update the document even though the lock is not yet released.

xdmp:lock-acquire("/inventory/hassan", "exclusive", "0", "This lock is acquiuired by admin user", 60)

We have another user called "shiv" with the "admin" role assigned to it, still, "shiv" user can execute the below function and modify the document even though the lock is not yet released.

xdmp:node-replace(doc("/inventory/hassan")//location, <location>ABC</location>)

We are using MarkLogic 10.0-.2.1

Please help me to find out what is wrong going on here.

2

There are 2 answers

0
Mads Hansen On BEST ANSWER

It seems that if you are using a user with admin it is bypassing the lock.

When I lock a document with one user, and then attempt to modify it with a different unprivileged, user I get the following:

[1.0-ml] XDMP-LOCKED: xdmp:node-replace(fn:doc("/test.xml")/doc/location, <location>ABC</location>) -- Document or Directory is locked

However, after giving that user the admin role, it executes successfully and updates the document.

3
hunterhacker On

This lock is not a transaction lock. As the docs say:

Note that the lock described here is a relatively heavy persistent document lock for file system emulation through WebDAV, not a relatively light transaction lock for database consistency.

https://docs.marklogic.com/xdmp:lock-acquire