13

Background: I'm moving my application from mssql to npgsql v2.0.11.92. After a few minutes or hours of running my application, I get a System.Exception: Timeout while getting a connection from the pool.

I'm using lib version 2.0.11.92 in x86 environment on x64 platform. All connections are closed and disposed in finally block at the latest, but after a while, I receive the error. So, it should be a problem of the Npgsql library.

In my application, there are lots of queries happening in the background every few seconds, but most of the times, they're just running sequentially, not in paralell.

My used connection string is: SERVER=mydbserver;MINPOOLSIZE=3;MaxPoolSize=15;ConnectionLifeTime=7;DATABASE=Test DB;UID=user;PWD=pass

I'm trying to diagnose leaking postgres connections in npgsql.

FYI: The Npgsql library had already got a leaking problem which has been fixed in latest version 2.0.11.92. But still there are some problems, I assume.

Has anybody experienced similar problems with the current library version (npgsql v2.0.11.92) ?

Jochen
  • 380
  • 1
  • 3
  • 9

1 Answers1

11

I had the same problem. The solution is to turn off connection pooling. You do this in the connection string before connecting to the database from your c# app

In your connection string:

Pooling=false;
flofreelance
  • 944
  • 3
  • 14
  • 31
Arya
  • 8,473
  • 27
  • 105
  • 175
  • 8
    Turning off connection pooling is not exactly solution. Let's call it workaround. – IvanP Feb 08 '14 at 11:03
  • Turning it off allowed it to work, still need to figure out why connection pooling isn't working. – Cody Jan 13 '15 at 20:50
  • @ValentinKuzub because the connection pooling in npgsql is buggy! – Arya Aug 22 '16 at 14:58
  • I'm not sure why some people are downvoting my answer. The connection pooling with npgsql is buggy. – Arya Aug 22 '16 at 14:59