[Mulgara-dev] Read-only Transactions

Life is hard, and then you die ronald at innovation.ch
Fri May 23 18:55:29 UTC 2008


On Fri, May 23, 2008 at 11:09:10AM -0700, Paul Gearon wrote:
> I haven't looked at this interface either, but Andrae said he'd
> documented something on it. I'm not sure where he'd have put that, but
> what about the Wiki?
> 
> Otherwise, Ronald should know about it. Hopefully he'll be up soon.  :-)

Ok, I'm up :-)

And yes, Andrae checked in some documentation, under the docs:
http://www.mulgara.org/trac/browser/trunk/docs/site-src/design/JTAInterface.txt

> On Fri, May 23, 2008 at 10:53 AM, Alex Hall <alexhall at revelytix.com> wrote:
> > I remember reading a message on this list from a couple of months ago
> > indicating that read-only transactions are now possible in Mulgara
> > thanks to the recent JTA work.  Can somebody please give a little bit of
> > details about how to start a read-only transaction that will span
> > multiple commands?  It would be very useful for the work I'm doing.

JTA doesn't per se provide any flag to pre-emptively indicate that a
transaction should be read-only (though a resource can signal at the
end of a transaction that there were no modifications, i.e. that as
far as it is concerned the tx was read-only). Therefore the approach
taken by Andrae (which seems to be a generally accepted approach) is
to provide two methods for getting the XAResource object:

  Session.getXAResource()
  Session.getReadOnlyXAResource()

I.e. all transactions using the first will result in the write-lock
being acquired, and transactions using the second will only be allowed
to perform read-only operations.

AFAIK there is no other way in Mulgara currently to ask for a
read-only transaction, except when you run in auto-commit mode in
which case mulgara will only acquire the write-lock if the operation
is a modification operation.

Note also that a given Session instance must be either used
exclusively via getXAResource()/getReadOnlyXAResource() or exclusively
via setAutoCommit()/commit()/rollback(); i.e. once you've invoked one
of these methods you may never invoke methods from the other group
(even if it's for a new transaction). So you can't do tricks like
getting a read-only XAResource and then using the non-JTA transaction
methods.


  Cheers,

  Ronald




More information about the Mulgara-dev mailing list