Steve,

If I understand your situation correctly, and if I understand chapter 3 of the Developers Guide correctly, the transaction model should lock the documents for you, and you shouldn't need anything extra. You might want to review that chapter to see how the transaction model works (http://developer.marklogic.com/pubs/).

-- Mike

Steve wrote:
I've got an XQuery module that has an if-then-else statement that
inserts data into a document. The basic flow is:

let $testNode := doc($docName)/doc/keywords/[EMAIL PROTECTED] eq $testKeyword]
  return
  (
     if (fn:exists($testNode)) then
     (
        (: Update the document by replacing the $testNode :)
     )
    else
    (
       (: Update the document by inserting a new node :)
     )
  )

I'm invoking this module using the Java XCC API. The Java program that
executes the request has multiple threads, all connecting as the same
MarkLogic user. The problem is that if two threads hit the
fn:exists(..) check at the same time then multiple nodes are inserted.
Is there any way that I can stop this happening by acquiring a lock on
the document before updating it? I've looked at the
xdmp:local-acquire(..) function, but that locks the document to the
current user, and as the threads are connecting as the same user, this
won't help the situation.
_______________________________________________
General mailing list
General@developer.marklogic.com
http://xqzone.com/mailman/listinfo/general

_______________________________________________
General mailing list
General@developer.marklogic.com
http://xqzone.com/mailman/listinfo/general

Reply via email to