简体   繁体   English

npgsql 连接池重复认证

[英]npgsql connection pool repeated authentication

I'm using Npgsql.EntityFrameworkCore.PostgreSQL 2.1.2, EfCore 2.2, asp.net 3.1.我正在使用 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).如您所见,似乎每次执行新的身份验证(需要 300 毫秒)。 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.我还尝试添加 dbcontextpooling,结果保持不变。 Any hint?有什么提示吗?

My Bad, I found out that each time a connection was closed we were emptying the pool explicitly:(糟糕的是,我发现每次关闭连接时,我们都会明确清空池:(

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM