[MarkLogic Dev General] Question about Locks

Michael Blakeley michael.blakeley at marklogic.com
Thu Jun 21 18:06:55 PDT 2007


Bilal,

I can release locks without a problem.

(: Q1 :)
doc('test.xml')
=> <x><a id="1"/></x>

(: Q2 :)
xdmp:lock-acquire(
   "test.xml", "exclusive", "0",
   "document being updated", xs:unsignedLong(600))
=> ()

(: Q3 :)
xdmp:lock-release('test.xml')
=> ()

Perhaps you are trying to acquire and release the same lock in the same 
query? That is indeed a conflicting update, because you are updating the 
same lock in the same way within the same transaction.

Have you read chapter 4 of the Developer's Guide? It discusses some 
important concepts behind MarkLogic Server transactions.

   http://developer.marklogic.com/pubs/

Note that you may not need to lock the document at all. If you're simply 
updating a document, the server will automatically obtain a write-lock 
for your query's transaction. When the query completes, the transaction 
automatically commits and also releases the lock.

If you are implementing CMS-like functionality, and checking the 
document out with a persistent lock, then you must rethink your query 
logic. You will only be able to change the state of the lock once within 
a given query. So find a way to either lock or not lock the document, 
once and for all.

-- Mike

Bilal Khalid wrote:
> Hello,
> 
> If a document lock is acquired with a time-limit (e.g. xdmp:lock-acquire("
> mydocument.xml", "exclusive", "0", "document being updated",
> xs:unsignedLong(600))), is it possible to release said lock using the
> xdmp:lock-release() function before the specified time limit expires? I get
> XDMP-CONFLICTINGUPDATES errors when I attempt that.
> 
> -Bilal
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://xqzone.com/mailman/listinfo/general

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4532 bytes
Desc: S/MIME Cryptographic Signature
Url : http://xqzone.marklogic.com/pipermail/general/attachments/20070621/db9340aa/smime.bin


More information about the General mailing list