gpt4 book ai didi

postgresql - psql 和 npgsql 之间的 pg_settings 差异

转载 作者:行者123 更新时间:2023-11-29 13:41:29 24 4
gpt4 key购买 nike

当连接到 pg 11 实例并执行时

select setting, source from pg_settings
where name='tcp_keepalives_interval';

我在通过 psql 连接和使用 using Npgsql;

的脚本之间得到两种不同的响应

命令行psql客户端返回

0   | default

而 Npgsql 脚本将返回

75  | default

75 匹配 net.ipv4.tcp_keepalive_intvl 但我仍然期望 0。

造成这种差异的原因是什么?我通常如何在 C# 中使用 Npgsql 来解释它?

最佳答案

查看我的 Crystal 球,我发现您的数据库服务器不在 Windows 上,psql session 正在数据库服务器上运行。您的 psql session 通过 UNIX 套接字(本地 连接)连接。

The documentation说(强调我的):

keepalives_count

Controls the number of TCP keepalives that can be lost before the client's connection to the server is considered dead. A value of zero uses the system default. This parameter is ignored for connections made via a Unix-domain socket, or if keepalives are disabled. It is only supported on systems where TCP_KEEPCNT or an equivalent socket option is available; on other systems, it has no effect.

如果您通过 TCP 连接 psql,您也应该看到 75。

关于postgresql - psql 和 npgsql 之间的 pg_settings 差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54771398/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com