Hi Pradeep,
Conflicting updates occur whenever you try to update the same node tree within one transaction. Properties are stored as XML fragment, and can therefore cause conflicting updates just as well. Updating both document and properties doesn’t conflict as they are stored as separate fragments. If you can’t control how often a property gets updated within one transaction, then you can best cumulate all changes first in a map:map, and only write that until you are sure everything is done. I used a similar approach for cumulating cookie updates. By the way, you can’t catch a conflicting update with just a try-catch around the statement, but I though you could if you would wrap all the updating statements within an eval or invoke.. not entirely sure though, and you might need to run the updates in a isolated transaction for this to work, but perhaps worth a try in your case? Kind regards, Geert *Van:* [email protected] [mailto: [email protected]] *Namens *Pradeep Maddireddy *Verzonden:* maandag 22 april 2013 11:28 *Aan:* MarkLogic Developer Discussion *Onderwerp:* 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]> 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]] *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] http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
