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

WFLY-6215 Don't allow afterCompletion callbacks to happen when an inv… #8745

Merged
merged 1 commit into from
Jul 20, 2016

Conversation

stuartwdouglas
Copy link
Contributor

…ocation is in progress

} else if (state == SYNC_STATE_AFTER_COMPLETE_DELAYED) {
try {
//we know the transaction did not commit, as we are still active in the tx, this only happens through timeout
handleAfterComplection(false, instance, toDiscard);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it is relevant but should we comment that other SessionSynchronization callbacks will have run already in the background (tm reaper) thread?

@scottmarlow
Copy link
Contributor

retest this please

break;
} else if (state == SYNC_STATE_AFTER_COMPLETE_DELAYED) {
try {
//we know the transaction did not commit, as we are still active in the tx, this only happens through timeout
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another possibility is that the transaction was manually acquired through some user code or framework and committed this way. I think it's at least more consistent to track the transaction outcome and report it, even if it is very likely always to be false.

@ryanemerson
Copy link
Contributor

With this solution it is possible for EJB invocations to be executed on a SFSB after the Tx has rolledback and afterCompletion has already been executed. Shouldn't we throw an EJBTransactionRolledbackException to the client in this situation?

@stuartwdouglas
Copy link
Contributor Author

@ryanemerson I am not really sure what you mean? Can you elaborate on the scenario you are describing?

@ryanemerson
Copy link
Contributor

@stuartwdouglas Consider the following:

userTransaction.setTransactionTimeout(5);
userTransaction.begin();
sfsb.method1();
sfsb.method2();
.... 

In your solution, if the userTransaction timesout during sfsb.method1(), then sfsb.afterCompletion(...) is called, but no exception is thrown to the client, therefore sfsb.method2() will be executed after sfsb.afterCompletion(...).

I don't believe this is a violation of the specification, but I am not sure it is desirable behaviour. Would it not be better for sfsb.method2() to fail-fast and throw an exception to the client?

@stuartwdouglas
Copy link
Contributor Author

If CMP is in use method1() will throw an exception when the CMP interceptor attempts to commit the transaction. If BMP is in use then an exception will not be thrown until the user attempts to do something transnational, which I think is the correct behaviour, even though in some cases it may be counter intuitive. We can't throw exceptions unless the spec actually requires it.

@n1hility n1hility added the 10.x label Jun 2, 2016
@n1hility
Copy link
Member

n1hility commented Jun 2, 2016

@stuartwdouglas did you have a response or update to Scott and David's comments? I am thinking this would be an ideal 10.1 PR to merge.

@bstansberry
Copy link
Contributor

@stuartwdouglas ^^^

@scottmarlow
Copy link
Contributor

I'm not sure if WFLY-4923 is relevant to this change but also see my comments on #8731, which has the sync.afterCompletion callback check if the application has yet seen the transaction end, which is a hint as to whether the application thread or background reaper thread, should perform the afterCompletion action.

@n1hility
Copy link
Member

@stuartwdouglas ping ^

@stuartwdouglas
Copy link
Contributor Author

Linux failure looks like an unrelated remoting deadlock

@n1hility
Copy link
Member

Retest this please

@bstansberry bstansberry added the ready-for-merge Only for use by those with merge permissions! label Jul 20, 2016
@bstansberry bstansberry merged commit 966afaf into wildfly:master Jul 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge Only for use by those with merge permissions!
Projects
None yet
6 participants