2

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.

DevNinja
  • 1,459
  • 7
  • 10

2 Answers2

1

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

hunterhacker
  • 6,378
  • 1
  • 14
  • 11
  • Thanks for the reply, our requirement is to lock the document for a specific time, and that document should not be accessible for others during its lock time, what would be the solution for my use case? – DevNinja Nov 24 '20 at 15:49
  • If others can be made well behaved and call lock-acquire too then that works. It was designed for cooperative editing. Or you don’t even want it visible to others? – hunterhacker Nov 25 '20 at 17:08
  • It sounds as if they expect one user to obtain an exclusive lock, and any other users from being prevented from doing so. Might need to see if someone with `admin` is allowed to bypass that check. Does a user without the `admin` role get blocked? – Mads Hansen Nov 25 '20 at 17:50
1

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.

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147