Pradeep,

I see that behavior too (thanks for the excellent, self-contained example code).

I can only assume that recent versions of MarkLogic added some conflict 
checking that I was not aware of, which occurs before the transaction commit, 
but that it is not as universal as the checks the commit logic is able to do. 
Someone on the list from MarkLogic Engineering may be able to correct me if I'm 
wrong.

If you know the problem is with multiple properties, Geert's suggestion of 
putting them all in a map, keyed by URI with the required property for each 
URI, should work.

If you can tell us the nature of the problem, there may be other solutions as 
well.

Damon


From: [email protected] 
[mailto:[email protected]] On Behalf Of Pradeep Maddireddy
Sent: Monday, April 22, 2013 5:28 AM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Try Catch Conflicting updates

Hi Damon,

Thank you. Just one more observation

The first query seems to work fine, in every iteration we insert the same 
document and update its property try catch seems to work fine. But in the query 
two we insert the document only once and update the property twice throws  
conflicting updates error.
(: 
---------------------------------------------------------------------------------------------------------
 :)
(: query one  :)
let $uri := "/root/abc.xml"
for $prop in 1 to 2
return
    try
    {
        xdmp:document-insert($uri,<root/>),
        xdmp:document-set-property($uri,<priority>{$prop}</priority>),
        "Successfuly updated property."
    }
    catch($err)
    {
        "Error updating property."
    }
(: 
---------------------------------------------------------------------------------------------------------
 :)
(: query two :)
let $uri := "/root/abc.xml"
let $_ := xdmp:document-insert($uri,<root/>)
for $prop in 1 to 2
return
try
{

xdmp:document-set-property($uri,<priority>{$prop}</priority>),
"Successfuly updated property."
}
catch($err)
{
"Error updating property."
}
(: 
---------------------------------------------------------------------------------------------------------
 :)

Thanks
Pradeep Maddireddy

On Fri, Apr 19, 2013 at 8:09 PM, Damon Feldman 
<[email protected]<mailto:[email protected]>> wrote:
Pradeep,

The commit of all updates from a transaction occurs after the XQuery is done 
running, including the try/catch. So setting the properties did not trigger the 
conflict (or at least it is not detected) inside the try/catch. That code 
completes, then when the system actually processes the transaction commit after 
all code is done, it sees the same fragment being updated in inconsistent ways 
and raises the error.

So you need to look at your program logic to avoid the conflict. Can you 
describe what happens and what you are trying to accomplish at a high level?

Yours,
Damon

--
Damon Feldman
Sr. Principal Consultant, MarkLogic




From: 
[email protected]<mailto:[email protected]>
 
[mailto:[email protected]<mailto:[email protected]>]
 On Behalf Of Pradeep Maddireddy
Sent: Friday, April 19, 2013 10:15 AM
To: General Mark Logic Developer Discussion
Subject: [MarkLogic Dev General] Try Catch Conflicting updates

Hi..!

Try catch doesn't seem to work with conflicting updates problem. I am trying to 
update the same document property in the same transaction so I used try catch 
so that the second update can be ignored but doesn't seem to work. Marklogic is 
still throwing an hard error even when I am using a try catch in the below case.
Is there anything wrong in the below block of code.

My actual situation isn't as straight forward so I cannot use alternate 
approaches.

try {
(
xdmp:document-set-property("/root/abc.xml",<priority>5</priority>),
xdmp:document-set-property("/root/abc.xml",<priority>6</priority>)
)
}
catch($err)
{
  "error"
}

Thanks
Pradeep Maddireddy

_______________________________________________
General mailing list
[email protected]<mailto:[email protected]>
http://developer.marklogic.com/mailman/listinfo/general

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to