[XQZone General] Guaranteed unique?
jhunter at marklogic.com
Mon Nov 28 09:51:40 PST 2005
Stewart, Joel (LNG-DAY) wrote:
> I have been wondering how to accomplish this when needing to call it a
> number of times from within an xquery function, e.g.:
> One idea is to use eval-in. I have been wondering if using that to put
> your ids in another database would work around the above issue.
> Apparently it does.
Yes, that's a viable approach to executing and committing an update in
the middle of a larger query.
> So, running this will work. The hard part will be putting error
> handling and retry logic in the function calling it - if it so happens
> two threads get on that node at the same time and cause conflicting
Actually that won't cause conflicting updates; that will just cause the
second thread to block until the first update is finished. A
conflicting update happens only at the end of a single query when the
multiple changes requested within that query conflict with each other.
For example: adding a node to a parent, then deleting the parent. You
presently can't do that because the two changes within the same query
step on each other's toes.
So your solution above is more robust than you thought. :)
> But I think this goes a long way toward what is needed to be
> implemented natively in marklogic - some "autoincrement" function that
> is not bound to the same rollback, and is atomic such that you will not
> get the conflicting updates exception.
I'll make sure that's added to the requested features list.
More information about the General