[jboss-jira] [JBoss JIRA] (WFLY-10258) Prevent enlisting additional resources on EJB caller side in case of server side @RequiresNew
Ondra Chaloupka (JIRA)
issues at jboss.org
Fri Apr 20 10:16:01 EDT 2018
[ https://issues.jboss.org/browse/WFLY-10258?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13564395#comment-13564395 ]
Ondra Chaloupka edited comment on WFLY-10258 at 4/20/18 10:15 AM:
------------------------------------------------------------------
[~dmlloyd] a good point, agree and on top of it I can see you already implemented the functionality ;-P
Anyway, if you permit a small side step:
I think it would be a hard to involve your idea about using {{XAResource.end}} call to decide about the resource future. First the {{XAResource}} API is not providing way to return a value back to the caller (https://docs.oracle.com/javaee/7/api/javax/transaction/xa/XAResource.html#end-javax.transaction.xa.Xid-int-). The other issue is the Narayana implementation which calls the {{.end}} just before {{prepare}} call on the each {{XAResource}} (https://github.com/jbosstm/narayana/blob/master/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore/XAResourceRecord.java#L210). Refactoring the code and moving the {{end}} call to some top-level place where the decision about 1PC/2PC is done (https://github.com/jbosstm/narayana/blob/master/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java#L2168) I consider difficult.
Back to the prior point:
As I was investigating your point I can see that the wfly transactional client delists itself from the current transaction in {{beforeCompletion}} calllback when it knows there was no work done (https://github.com/wildfly/wildfly-transaction-client/blob/master/src/main/java/org/wildfly/transaction/client/XAOutflowedResources.java#L79). That's good but delisting at the Narayana side (https://github.com/jbosstm/narayana/blob/master/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java#L904) seems not removing the xa resource from the list (https://github.com/jbosstm/narayana/blob/master/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java#L3719) which defines if 1PC is applied.
{code}
Thread [default task-2] (Suspended (breakpoint at line 129 in SubordinateXAResource))
owns: Object (id=531)
SubordinateXAResource.end(Xid, int) line: 129
TransactionImple.delistResource(XAResource, int) line: 897
LocalTransaction.delistResource(XAResource, int) line: 162
XAOutflowedResources$1.beforeCompletion() line: 74
921870613.accept(Object) line: not available
1900321310.accept(Object, Object) line: not available
LocalTransaction(AbstractTransaction).performConsumer(ExceptionBiConsumer<T,U,E>, T, U) line: 209
LocalTransaction(AbstractTransaction).performConsumer(ExceptionConsumer<T,E>, T) line: 220
AbstractTransaction$AssociatingSynchronization.beforeCompletion() line: 265
SynchronizationImple.beforeCompletion() line: 76
AtomicAction(TwoPhaseCoordinator).beforeCompletion() line: 368
AtomicAction(TwoPhaseCoordinator).end(boolean) line: 91
AtomicAction(AtomicAction).commit(boolean) line: 162
TransactionImple.commitAndDisassociate() line: 1289
TransactionManagerImple(BaseTransaction).commit() line: 126
TransactionManagerDelegate(BaseTransactionManagerDelegate).commit() line: 89
LocalTransaction.commitAndDissociate() line: 73
ContextTransactionManager.commit() line: 71
CMTTxInterceptor.endTransaction(Transaction) line: 88
CMTTxInterceptor.invokeInOurTx(InterceptorContext, EJBComponent) line: 261
CMTTxInterceptor.required(InterceptorContext, EJBComponent, int) line: 362
CMTTxInterceptor.processInvocation(InterceptorContext) line: 144
InterceptorContext.proceed() line: 422
{code}
*/edit* I found the started discussion at the forum: https://developer.jboss.org/message/982119
was (Author: ochaloup):
[~dmlloyd] a good point, agree and on top of it I can see you already implemented the functionality ;-P
Anyway, if you permit a small side step:
I think it would be a hard to involve your idea about using {{XAResource.end}} call to decide about the resource future. First the {{XAResource}} API is not providing way to return a value back to the caller (https://docs.oracle.com/javaee/7/api/javax/transaction/xa/XAResource.html#end-javax.transaction.xa.Xid-int-). The other issue is the Narayana implementation which calls the {{.end}} just before {{prepare}} call on the each {{XAResource}} (https://github.com/jbosstm/narayana/blob/master/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore/XAResourceRecord.java#L210). Refactoring the code and moving the {{end}} call to some top-level place where the decision about 1PC/2PC is done (https://github.com/jbosstm/narayana/blob/master/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java#L2168) I consider difficult.
Back to the prior point:
As I was investigating your point I can see that the wfly transactional client delists itself from the current transaction in {{beforeCompletion}} calllback when it knows there was no work done (https://github.com/wildfly/wildfly-transaction-client/blob/master/src/main/java/org/wildfly/transaction/client/XAOutflowedResources.java#L79). That's good but delisting at the Narayana side (https://github.com/jbosstm/narayana/blob/master/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java#L904) seems not removing the xa resource from the list (https://github.com/jbosstm/narayana/blob/master/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java#L3719) which defines if 1PC is applied.
*/edit* I found the started discussion at the forum: https://developer.jboss.org/message/982119
> Prevent enlisting additional resources on EJB caller side in case of server side @RequiresNew
> ---------------------------------------------------------------------------------------------
>
> Key: WFLY-10258
> URL: https://issues.jboss.org/browse/WFLY-10258
> Project: WildFly
> Issue Type: Bug
> Components: EJB, Transactions
> Affects Versions: 12.0.0.Final
> Reporter: Jörg Bäsner
>
> Scenario:
> - server-1 (intermediary)
> -- Running standalone profile
> -- Has a remote-outbound-connection pointing at server-2 through server-2's public IP address
> -- Intermediary bean need to lookup the Target bean in server-2 and also inject the {{TransactionManager}}
> -- Intermediary bean need to enlist a _dummy_ XAResource
> - server-2 (target)
> -- disable {{JBOSS-LOCAL-USER}} auth
> -- Target bean needs to be annotated with {{@REQUIRES_NEW}} (important)
> - Standalone EJB client invokes an intermediary bean server-1, which as a result invokes target bean on server-2.
> The _dummy_ XAResource should log in the {{commit}} method whether one-phase optimization is being used like:
> {code}
> @Override
> public void commit(Xid arg0, boolean onePhaseOptim) throws XAException {
> logger.info("-- Committing in the client resource. One-phase optimisation is: " + onePhaseOptim + " --"
> + (onePhaseOptim ? "" : " -> TWO-PHASE COMMIT !!!"));
> }
> {code}
> In this scenario it is expected that the one-phase optimization is being used!
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
More information about the jboss-jira
mailing list