When does Nuxeo return client connections to PSQL?

I have a Structure template which creates a document tree for my application. When each of the three documents are created they fire an event handler which creates a custom title for each of the document based on the context and the documents parents.

The Structure is 3 levels deep inside a Workspace. Workspace -> 1…N Root Documents -> 1…N Children-> 10-20 GrandChildren for each child. The root, children and grandchildren are folderish and can be different document types but only on their unique level. Each of these document types has separate schema which is linked to the specific document type.

If I create several root documents in a row, which generates children and grandchildren documents and fires the event handlers mentioned above I will get the error below at different places in a given creation test.

It seems the PSQL client connections are “leaking” because once Nuxeo gives the error below only a reboot will get it to work properly.

My question is how can I be sure I am “returning” the PSQL Clients so they do not leak?

I don't want to just increase the client count because it seems that will just “mask” the problem and not solve the root cause.

  50912 2012-05-03 12:51:26,520 WARN  [org.hibernate.util.JDBCExceptionReporter] SQL Error: 0, SQLState: 53300
  50913 2012-05-03 12:51:26,521 ERROR [org.hibernate.util.JDBCExceptionReporter] FATAL: sorry, too many clients already
  50914 2012-05-03 12:51:26,526 ERROR [org.nuxeo.ecm.automation.core.events.OperationEventListener] Failed to handle event documentCreated using chain: besCreateProcessSkinRecipe
  50915 org.nuxeo.ecm.automation.OperationException: Failed to invoke operation Context.SetVar
  50916         at org.nuxeo.ecm.automation.core.impl.InvokableMethod.invoke(InvokableMethod.java:144)
  50917         at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.doInvoke(CompiledChainImpl.java:114)
  50918         at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.invoke(CompiledChainImpl.java:96)
  50919         at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.doInvoke(CompiledChainImpl.java:117)
  50920         at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.invoke(CompiledChainImpl.java:96)
  50921         at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.doInvoke(CompiledChainImpl.java:117)
  50922         at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.invoke(CompiledChainImpl.java:96)
  50923         at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.doInvoke(CompiledChainImpl.java:117)
  50924         at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.invoke(CompiledChainImpl.java:96)
  50925         at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.doInvoke(CompiledChainImpl.java:117)
  50926         at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.invoke(CompiledChainImpl.java:96)
  50927         at org.nuxeo.ecm.automation.core.impl.OperationServiceImpl.run(OperationServiceImpl.java:85)
  50928         at org.nuxeo.ecm.automation.core.operations.execution.RunDocumentChain.run(RunDocumentChain.java:57)
:
0 votes

1 answers

2270 views

ANSWER



Inside a transaction only one connection to the database should be used for document management for a single repository (it is fetched from a pool). The connection is returned to the pool at transaction commit/rollback time.

But here your error is raised by org.hibernate.util.JDBCExceptionReporter so it's a hibernate problem, which could be from a number of things (JPA, jBPM), but is not due to Nuxeo Core. Aren't there any stack traces about what is in the process of using hibernate when it fails to get more connections?

0 votes



I will look for the "other" stack traces, this is a intermittent problem which I will address as time allows. I will however, address it eventually.
05/07/2012

I finally got some time to look into this problem.

Error is:

11936 2012-05-16 09:59:58,397 ERROR [org.hibernate.util.JDBCExceptionReporter] Cannot get a connection, pool error Timeout waiting for idle object

I did a bit of research and found this (http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html#Preventing_dB_connection_pool_leaks) tutorial on connection pool leaks.

I will open a new question and ask follow-up questions there.

05/16/2012