Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Npgsql: Timeout while getting a connection from the pool

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) ?

like image 745
Jochen Avatar asked Apr 05 '12 12:04

Jochen


1 Answers

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;
like image 82
Arya Avatar answered Sep 20 '22 02:09

Arya