Hi Ryan,

Transactions are within a single database, so you cannot do this as a single 
transaction.

You could use distributed transactions (XA), and this is really the use case it 
is designed for.  But it might be overkill.

How long do these updates take?  If they only take a few seconds, you could put 
some logic in your application to wait until everything is committed like the 
following:

1) insert a document in one of the dbs that indicates that you started your 
updates
2) add code to your app that has a for loop that evals another query (it must 
be in a different transaction) to see if the above document exists, and if it 
does, sleep for a second, then continues in the loop.  If the doc does not 
exist, it invokes the module (so it is in a new transaction) that was 
originally called.
3) do your updates to all three databases
4) delete the document added in step 1
5) delete the extra code added in step 2

It is a little hacky, but the effect will be for the few people that try to 
access the system during these updates, they will see a small delay in their 
response.  You might be able to do this in a URL rewriter too.

Just an idea, untried and untested.

-Danny
________________________________________
From: general-boun...@developer.marklogic.com 
[general-boun...@developer.marklogic.com] On Behalf Of seme...@hotmail.com 
[seme...@hotmail.com]
Sent: Wednesday, April 18, 2012 7:36 PM
To: general@developer.marklogic.com
Subject: [MarkLogic Dev General] Possible to coordinate an update across DBs to 
commit at the same time?

Say I have three databases: A, B, and Modules. I want to be able to deploy 
changes to all three and have the changes all commit (or become active) at the 
same time.

I may have new config files that only work with the new code going into Modules 
so I don't want to put the config files in A and then afterwards insert the new 
code in Modules because there may be a gap in time where the config files and 
the code are not the right versions for each other. I don't want to have any 
downtime so stopping the server is not really any option. How can I insert my 
new files across the DBs and have the changes take place simultaneously?

Perhaps I can have the app run at a particular timestamp and then insert all 
the new files and then remove the run-at timestamp. I'm not sure this works for 
the Modules DB though.

Another option may be to put version info in the XML files in database A, then 
write the new code in the Modules DB under a new directory and write the code 
to only use the files in A with the new version, then change the modules root 
of the app server to the newer code dir (thus automatically only using the new 
version of files in A).

I'll take "within a few microseconds" if "simultaneous" isn't really possible. 
Anyone know how to do this?

Thanks!

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

Reply via email to