Might be a dummy question, but I'm risking it anyway... Is it possible for an add-on to cause a DB connection leak in JIRA? Assuming the add-on uses nothing else than the ActiveObjects class to query the database and that the add-on never gets a hold on the Connection object, my assumption is that the answer is no. But I might me missing something... Could there be ways of using ActiveObjects that would cause it not to free DB connections?
Community moderators have prevented the ability to post new answers.
Since add-ons have access to essentially anything in the JVM, it is absolutely possible for an add-on to cause a connection leak, and this has happened many times in the past.
First, the obvious problems... JIRA's OfBizDelegator
is available in the API and the raw entity-engine transaction-related classes are de facto API by virtue of transitive dependencies. It is quite easy to leak a connection by doing something naughty through them. Examples include:
findListIteratorByCondition
or any of the other methods that return OfBizListIterator
and failing to close()
it;TransactionUtil
and failing to ever commit it or roll it back. In a request thread this would be caught by RequestCleanupStep
, but that protective safeguard is lost if the add-on creates its own thread pool. The reason starting a transaction and failing to close it leaks a connection has to do with the way that entity-engine manages connections. Normally, connections are immediately returned to the thread pool, but if you start a transaction then it is held in a ThreadLocal until you commit it.Further, nothing actually forces an add-on to stick with the API. It can go directly to the jira-core
class OfBizConnectionFactory
, call getConnection()
on it, and go to town.
Finally, even in the Active Objects world, it is possible to get a raw Connection
by using EntityManager.getProvider().getConnection()
. Several of the more advanced add-ons do this to get more control over their queries on the Active Objects tables when they run into AO's limitations.
In short, yes.
Thanks Chris, very clear.
So basically, if an add-on sticks with using the standard AO query API and uses declarative transactions, it should stay out of trouble, DB-connection wise...
Cheers,
Marc
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.