EntityBean instances are leaked from pool on certain exceptions
---------------------------------------------------------------
Key: WFLY-4569
URL:
https://issues.jboss.org/browse/WFLY-4569
Project: WildFly
Issue Type: Bug
Components: EJB
Affects Versions: 8.2.0.Final, 9.0.0.Beta2, 9.0.0.CR1
Reporter: Alexey Makhmutov
Assignee: Alexey Makhmutov
Fix For: 9.0.0.CR2, 10.0.0.Alpha1
Entity beans instances may not be returned to the pool after certain exceptions, which
may lead to pool exhaustion.
Currently, following two cases are discovered:
# If any exception is thrown from ejbCreate method (e.g. duplicate record was found in
the database), then bean instance won’t be returned to the pool, as there are no
try-finally statements around call to ejbCreate in
EntityBeanEjbCreateMethodInterceptor/EntityBeanRemoteViewInstanceFactory classes for this
call.
# If runtime exception (such as EJBException) is thrown from business method, then
instance won’t be returned to the pool, as it will be marked as discarded by
EntityBeanAssociatingInterceptor and both
ReferenceCountingEntityCache/TransactionLocalEntityCache cache implementations just
ignores discarded instance on release call.
These problems actually make impossible using of pooled instances with Entity beans, as
number of used beans from pool will be steadily increasing in production until pool is
exhausted and clients start getting ‘Failed to acquire permit’ exceptions.
Here is the set of integration tests, which examines the described behavior:
https://github.com/Lerm/jboss-as/commit/f3eadd96d84dabc0a8b9c6c866ccfd5fe...