[MarkLogic Dev General] Transaction hangs db

Henrik Thiil Nielsen henrikthiil at post1.dansknet.dk
Fri Aug 31 10:19:07 PDT 2012

Thanks, Mike! 

Using commas instead of semicolons did the trick. And now I even have access
to my global variables in each statement. 

I am sure you're right about learning to do updates without the
transactions. It's just that I keep bumping into "conflicting update" errors
all the time, so I was trying the transactions just to have a plan B.
My next experiment will be to build a new in-memory node complete with all
sub-nodes and then use it to do  a single update of the corresponding node
in the document in the db. I hope that can be done without 
conflicting updates.

RE version of ML:  I am in fact using 5.0-3.3. (64 bit, on Windows 7). 

Now this is not to quibble, but as I re-checked the chapter in App
Developers' Manual on transactions I noticed this example (p32)):

xquery version "1.0-ml";
declare option xdmp:transaction-mode "update";
(: Begin transaction 1 :)
xdmp:document-insert('/docs/mst1.xml', <data/>);
(: This statement runs in the same txn, so sees /docs/mst1.xml :)
xdmp:document-insert('/docs/mst2.xml', fn:doc('/docs/mst1.xml'));
(: Transaction ends, updates visible in database :)

Just like my first solution it separates statements with semicolons,
including the last one before the commit. Now your advice clearly worked, so
is this example from the manual incorrect or does it 
differ subtly from what I did? It does include  two  statements separated by
a comma, but still the last one is followed by a semicolon...

Thanks again!


What version of the server are you using?

That semicolon after the node-replace acts just like a commit, so the
explicit xdmp:commit is probably trying to commit an empty update statement.
That extra, empty commit seems to be harmless with cq and 5.0-3.3, but your
environment may be different. Try something more like the docs example for
xdmp:commit, with a commas rather than a semicolons:

xdmp:document-insert("/docs/mydoc.xml", <myData/>),

It might be better to learn how to update MarkLogic documents without using
semicolons or xmdp:commit, before jumping into those advanced features.
Mostly they aren't necessary, and they add extra complexity.

-- Mike

More information about the General mailing list