[Mulgara-dev] transaction implementation
Life is hard, and then you die
ronald at innovation.ch
Tue Jul 1 08:41:34 UTC 2008
Hi,
while these questions are primarily directed at Andrae, I thought I'd
ask them here so some of this information gets spread around a bit.
While looking at and fixing some issues with the transactions, I
noticed a few things that I think could be improved, but would like to
make sure I'm not missing something.
First of all, the MulgaraInternalTransactionFactory and
MulgaraExternalTransactionFactory are scoped per Database (i.e. per
SessionFactory); however, all methods require a Session parameter, and
indeed all data managed by these factories is on a per-session basis
with no cross-session operations. Wouldn't it therefore be better to
make instances of these session-scoped in the first place? That way
not only are the data structures simplified, but we can get rid of the
mutex and thereby reduce the potential for deadlocks. I.e. is there
any future reason why these instances should stay session-factory
scoped? (Btw., I've make this change in my local repository and
verified it works and have not overlooked anything regarding the
current state of things).
Second, there appears to be some duplication of functionality between
both MulgaraInternalTransactionFactory and
MulgaraExternalTransactionFactory, and between
MulgaraInternalTransaction and MulgaraExternalTransaction (e.g. the
timeout handling and the transaction abortion). It would seem like a
cleaner approach if MulgaraInternalTransaction(Factory) instead were a
wrapper around MulgaraExternalTransaction(Factory). In this setup
MulgaraInternalTransactionFactory would start a JTA (Jotm) transaction
and enlist the XAResource from MulgaraExternalTransaction, and
MulgaraInternalTransaction would then just need to manage the
suspension and resumption of transactions and could leave most of the
transaction cleanup/abort code to the MulgaraExternalTransaction
implementation; similarly MulgaraInternalTransactionFactory could be
noticeably simplified.
Btw. I've added some uml sequence diagrams of the current state of
things to the http://www.mulgara.org/trac/wiki/TransArch2 wiki page.
Cheers,
Ronald
More information about the Mulgara-dev
mailing list