Bug 1094380 - (6.4.z) Multi threaded ejb invocations via remote-naming produce EJBCLIENT000025 if the Context is closed
Summary: (6.4.z) Multi threaded ejb invocations via remote-naming produce EJBCLIENT000...
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Naming
Version: 6.1.0,6.2.0,6.1.1,6.2.1,6.2.2
Hardware: Unspecified
OS: Unspecified
Target Milestone: CR2
: EAP 6.4.1
Assignee: Enrique Gonzalez Martinez
QA Contact: Jan Martiska
Russell Dickenson
Depends On:
Blocks: 1170672 eap641-payload
TreeView+ depends on / blocked
Reported: 2014-05-05 14:44 UTC by wfink
Modified: 2018-12-04 17:53 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2017-01-17 09:58:37 UTC
Type: Bug

Attachments (Terms of Use)
TestCase (19.69 KB, application/zip)
2015-04-28 08:38 UTC, Enrique Gonzalez Martinez
no flags Details

System ID Priority Status Summary Last Updated
Red Hat One Jira Issue Tracker WFLY-3316 Major Resolved Multi threaded ejb invocations via remote-naming produce EJBCLIENT000025 if the Context is closed 2016-02-05 01:33:52 UTC

Description wfink 2014-05-05 14:44:50 UTC
Description of problem:
If different Threads are creating different InitialContext with the same remote-naming approach closing the InitialContext will have effect to other threads.

The reproducer is attached to https://issues.jboss.org/browse/WFLY-3316 and can be used the same way (with the URL= remote://localhost:4447)

Comment 1 Enrique Gonzalez Martinez 2014-12-04 12:50:55 UTC
The problem here is in the naming component.

When several threads are using EJBContext the NamingStoreCache is mixing context among threads. 

Cache problem & race condition description

When the InitialContext creates a new RemoteNamingStore, *The cache is not taking into account the EJBClientHandler*. This EJBClientHandler could have different EJBClientContextIdentifier. 

When a remote ejb is invoked every thread is using the same RemoteNamingStore therefore the same EJBClientContext during an invocation (in this case because the endpoint data is the same).

This leads to a race condition:
ThreadA: close the context (raising the closed flag in the ejbcontext)
ThreadB: tries to invoke the context. It raises the error EJBCLIENT000025.
(both threads are using the RemoteNamingStore, therefore the same EJBClientHandler and EJBClientContext).

Note for Wildfly :
It also happens that EJBClientContext is executed before the RemoteNaming.CloseTask leading to a new stacktrace. (this happens for jboss-remote-naming 2.0.3.Final and jboss-remoting 4.0.5.Final due to the shutdown of the ExecutorService in EJBClientContext::close call.

Comment 2 Enrique Gonzalez Martinez 2014-12-04 15:02:45 UTC
Naming component

2.x upstream component PR 

1.x component PR 

Comment 3 Rostislav Svoboda 2015-04-23 14:24:30 UTC
Please provide test (as discussed with Carlo) to include this in CP01 payload.
I will qa_ack afterwards.

Comment 4 Enrique Gonzalez Martinez 2015-04-28 08:38:59 UTC
Created attachment 1019572 [details]

Providing test case:

   mvn test

the dependency for the jboss.as should be modified to run the test. Property "version.org.jboss.as"

Comment 5 Jan Martiska 2015-05-15 08:10:51 UTC
Verified in EAP 6.4.1.CR2.

Comment 6 Petr Penicka 2017-01-17 09:58:37 UTC
Retroactively bulk-closing issues from released EAP 6.4 cummulative patches.

Note You need to log in before you can comment on or make changes to this bug.