Jonathan Halliday [
http://community.jboss.org/people/jhalliday] created the discussion
"Re: Remote Txn Inflow: Synchronizations"
To view the discussion, visit:
http://community.jboss.org/message/629394#629394
--------------------------------------------------------------
David
We need to be really careful discussing interposed syncs, because the term is overloaded
and hence ambiguous.
In the context of JTA 1.1,
TransactionSynchronizationRegistry.registerInterposedSynchronization has specific partial
ordering guarantees. However, as the JTA does not explicitly cover distributed tx
semantics, those ordering guarantees are relative to the other Synchronizations in the
same JVM only. We may or may not wish to offer wider guarantees or config options
according to how useful they are and how easy they are to implement.
The term 'interposition' also has meaning in distributed tx: a subordinate placed
between the root coordinator and eventual child resource or Synchronization to form a tree
structure. There are several ways of implementing that, including: Synchronization
objects may only be registered with their local node and are driven as part of that local
node's beforeCompletion phase. That phase may or may not itself be interposed to the
corresponding phase in the root coordinator. Alternatively, the local Synchronization may
be wrapped in a remote transport aware proxy and registered with the root (or an
intermediate parent if the tree is multi level) coordinator. In that case the
beforeCompletion phase in the child node is a no-op, the local Synchronization list being
empty. Naturally all three solutions display subtly different semantics and not so subtly
different performance characteristics.
The final piece of background you need before we continue on to implementation choices is
this: the transaction engine underpinning the JTA is not directly aware of the distinction
between JTA 'interposed' and regular Synchronizations. It does not maintain
separate lists for them, nor process them in separate phases. The necessary ordering
guarantees are achieved by sorting a single list of heterogeneous Synchronizations
elements using, amongst other things, their 'interposed' attribute. This impacts
how easy it is to expose separate lifecycle phases so the subordinate tx's lifecyle
can be driven in a more fine grained manner. Specifically, it's easy to expose
beforeCompletion and have it run all the Syncs, but considerably harder to expose separate
method for running regular and JTA-interposed syncs.
So, the options are:
Wrap the local subordinate tx object supplied by TS with an object that intercepts the
registerSynchronization calls and handles them itself, e.g. by proxying them individually
or as a group to the parent coordinator. Work needed on the TS side: none i.e. you
won't be held up waiting for us. IIRC various AS component already do something like
this for a local JVM case where they need ordering guarantees between their own Syncs that
exceed what can be done with JTA semantics.
Register Syncs with the local subordinate and register a single Sync in the parent, using
the impl thereof to pass the beforeCompletion call down to the subordinate coordinator.
Work needed on the TS side: none for beforeCompletion as it's already exposed. Some to
expose afterCompletion and allow some way for commit|rollback to indicate afterCompletion
processing should be deferred until an explicit call for it is made, as they currently
bundle it in automatically and must continue to do so in the default JCA case.
Allow JTA 1.1. 'interposition' ordering guarantees to span multiple nodes: Do it
using the first method above, except you either register two Syncs proxies (one regular,
one 'interposed') in the parent, or you register every child Sync in the remote
parent using its own individual proxy, using a type appropriate wrapper to preserve
ordering. Work needed on the TS side: none. Do it using method two above: lots, as the TS
core would need to be refactored to support handing multiple sync phases separately before
appropriate methods could be exposed for you to call. Don't hold your breath.
The joker in the pack is of course the failure semantics. In JTA all Synchronizations are
volatile (another overloaded term. 'in-memory only' rather than 'memory fence
aware' in this context). They are not logged to disk and hence afterCompletion calls
won't run in the event of a crash. Where everything is in one JVM that is relatively
easy to reason about. Where a crash may affect only one of the JVMs in an interposed
hierarchy, then you need to start worrying about detecting and cleaning up orphaned
afterCompletions that may never get called. A typical afterCompletion call is
'release connection back to pool', so leaking them is going to suck big time.
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/629394#629394]
Start a new discussion in JBoss Transactions Development at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]