npgsql connection pool repeated authentication

171 views Asked by At

I'm using Npgsql.EntityFrameworkCore.PostgreSQL 2.1.2, EfCore 2.2, asp.net 3.1.

Connection pooling is enabled (not passing it in the connection string). After enabling logging I'm getting logs like this:

2021-05-19 10:23:21.542 +02:00 Opening connection...
2021-05-19 10:23:21.545 +02:00 Attempting to connect to xxx.xxx.xxx.xxx:5432
2021-05-19 10:23:21.595 +02:00 Socket connected to xxx.xxx.xxx.xxx:5432
2021-05-19 10:23:21.597 +02:00 Authenticating...
2021-05-19 10:23:21.914 +02:00 A PostgreSQL type with the name hstore was not found in the database
2021-05-19 10:23:21.916 +02:00 A PostgreSQL type with the name citext was not found in the database
2021-05-19 10:23:21.918 +02:00 A PostgreSQL type with the name unknown was not found in the database
2021-05-19 10:23:21.921 +02:00 Opened connection to xxx.xxx.xxx.xxx:5432

This behavior is repeated for each query that's performed. As you can see, it seems that each time it performs a new authentication (it takes 300ms). Seen like this is seems that connection pooling is not working since I expect the connection to be reused each time. I also tryed to add dbcontextpooling, the result stays the same. Any hint?

1

There are 1 answers

0
vratojr On BEST ANSWER

My Bad, I found out that each time a connection was closed we were emptying the pool explicitly :(