0

We have a 3 tier application developed using WCF. Our Web Layer [32 bit Windows 2003 Sp1] calls the WCF service [64 bit Windows 2008 R2 on an NLB] which communicates with the Oracle 10g DB [ 64 bit Linux ]. DB connection is established using Nhibernate 2.2. WCF communication uses BasicHTTPBinding.

In a 32 bit test environment application works well, but on the Live environment as specified above we experience crashes. As per the logging the repetitive error is,

System.ApplicationException :> Inner Exception being

NHibernate.ADOException: While preparing select stderrorme0_.ERR_NO as ERR1_10_, stderrorme0_.ERR_TYPE as ERR2_10_, .... ...., from STD_ERROR_MESSAGE stderrorme0_ where stderrorme0_.ERR_NO=:p0 an error occurred ---> System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.

this error repeats, only that the table being fetched changes.

Temporary Solution: Restarting the WCF service hosted in IIS.

Please help us with your suggestions and solutions to get this to work. This post is raised after so many trial and errors following various blogs.

Radim Köhler
  • 122,561
  • 47
  • 239
  • 335
Arun RG
  • 3
  • 1
  • 1
    The most suspicious is *not* closed connection and/or *not* transaction see http://stackoverflow.com/q/1642252/1679310 – Radim Köhler Aug 16 '13 at 16:02

1 Answers1

0

This is almost certainly because of connections not being disposed of properly (https://stackoverflow.com/a/5442062/221708), which in your case may be caused by not disposing of NHibernate sessions properly. Just like you should wrap connections in using blocks, you should wrap NHibernate sessions in using blocks.

Here are a couple of good articles on managing NHibernate sessions in WCF:

Also remember that if you are using the sessionFactory.OpenSession(IDbConnection) overload, you are responsible for closing the connection returned by session.Close().

Community
  • 1
  • 1
Daniel Schilling
  • 4,829
  • 28
  • 60
  • Thanks Daniel, we will definitely check in our nHib environment for such non-disposed objects. But what is confusing us is that the application works fine all our test environments. Only when deployed in the Live environment we have such a problem. So one doubt that I have is, could any database configuration or privileges be causing this..? – Arun RG Aug 18 '13 at 04:42
  • Perhaps live environment gets more traffic, meaning more connections to the DB? Perhaps the test environment is deployed to more often, meaning more frequent WCF restarts? It is definitely an issue with the WCF service not releasing DB connections since restarting it fixes the problem for a little while. – Daniel Schilling Aug 19 '13 at 12:29