Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to determine transaction timeout #232

Open
miroch41 opened this issue Oct 29, 2024 · 0 comments
Open

No way to determine transaction timeout #232

miroch41 opened this issue Oct 29, 2024 · 0 comments

Comments

@miroch41
Copy link

There used to be a quite old discussion to this topic but I have a new comment related to Atomikos Transaction Essentials 6.0.0. I would like to interrupt the application thread if the associated transaction times-out, just in order to spare computational resources: the timeout is there exactly for this purpose. There were many discussions why Atomikos does not throw an exception in this case and I more or less agree that it is neither the responsibility of Atomikos to rollback the transaction immediately after timeout, nor to throw an exception. Well, there really can be XAResources which do not like rolling-back the transaction from within another thread.

Thus, it should be an application component (for example, in Spring, JtaTransactionManager) who should initiate the rollback after timeout. And indeed, there is a configuration parameter (failEarlyOnGlobalRollbackOnly of JtaTransactionManager) influencing exactly that. However, it does not work with Atomikos. And the reason is on Atomikos side. If the application component should initiate rollback on timeout, it must have been informed that the timeout has occurred (or must be able to actively retrieve this information). But Atomikos lacks such API: if a transaction times-out, Atomikos logs the warning and adds the RollbackOnlyParticipant. Well, this effectively disallows final commit but contributes nothing to propagating the information to the outside world. Actually, the transaction remains in status TxState.ACTIVE. Maybe, because of some internal reasons, may be it is because of some application cleanup (which is doubtful, as commit is already prohibited), but it is still active.

And the outside world (e.g. JtaTransactionManager) has the only API to call: userTransaction.getStatus(). Unfortunately, as the transaction remained active after timeout occurred, nothing suspicious is revealed and JtaTransactionManager must continue as if there were no timeout. The information about timeout is just actively hidden in Atomikos.

Compare this behaviour with another situation: if the application calls userTransaction.setRollbackOnly(). Now, irrespective of the true transaction state in Atomikos, this operation sets a TxRollbackOnlyStateHandler and thus a response from call to userTransaction.getStatus() signals an intention to abort.

Threfore, IMHO, there either should be a way, how to obtain the information about TX-timeout from Atomikos, or (preferred), after transaction times-out, not only RollbackOnlyParticipant should be added but also TxRollbackOnlyStateHandler set (similar to explicit call). This no way manipulates transaction from within another thread. Alternatively, this behaviour shall be configurable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant