我遇到过最不寻常的问题之一。
我的PostgreSQL数据库安装在windows服务器上,并监听所有ip地址:listen_addresses = '*'
我可以访问和发送查询,没有任何问题,在各种客户端设备,无论是linux或windows操作系统基础。
我只对一个特定的linux客户端有问题,如果我可以这样说的话,当查询响应稍微“重”一点时,这个客户机就无法执行查询。
我试着举例说明一下。
我在这台机器上有psql客户端,并且在具有大约20条记录的远程windows服务器上的postgresql数据库中有一个用户表,所以当我运行这个查询时:
select "firstName", "createdAt", "updatedAt", username from users limit 13;我通常会得到结果:
firstName | createdAt | updatedAt | username
-------------+-------------------------------+-------------------------------+-------------
User 1 | 2017-01-26 12:48:52.995+01 | 2017-01-26 12:48:52.995+01 | user1
User 2 | 2019-08-24 10:29:16.16329+02 | 2019-08-24 10:29:16.16329+02 | user2
User 3 | 2018-10-05 11:45:14.127813+02 | 2018-10-05 11:45:14.127813+02 | user3
User 4 | 2017-09-27 18:53:56.535867+02 | 2017-09-27 18:53:56.535867+02 | user4
User 5 | 2017-03-28 11:46:27.03684+02 | 2017-03-28 11:46:27.03684+02 | user5
User 6 | 2017-03-28 11:46:40.840481+02 | 2017-03-28 11:46:40.840481+02 | user6
User 7 | 2018-05-22 12:43:08.397247+02 | 2018-05-22 12:43:08.397247+02 | user7
User 8 | 2017-03-28 11:46:36.24854+02 | 2017-03-28 11:46:36.24854+02 | user8
User 9 | 2022-04-30 14:04:02.24541+02 | 2022-04-30 14:04:02.24541+02 | user9
User 10 | 2022-04-30 14:04:02.24541+02 | 2022-04-30 14:04:02.24541+02 | user10
User 11 | 2022-04-30 14:04:02.24541+02 | 2022-04-30 14:04:02.24541+02 | user11
User 12 | 2022-04-30 14:04:02.24541+02 | 2022-04-30 14:04:02.24541+02 | user12
User 13 | 2022-04-30 14:04:02.24541+02 | 2022-04-30 14:04:02.24541+02 | user13
(13 rows)任何限制为13的查询都会毫无问题地返回数据。
但是,在结果中再添加一行(查询中的限制为14 )之后,我立即得到如下结果:
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Succeeded.当我查询其他表时,我也会遇到同样的问题,低限制的数据将成功返回,但是当我在查询中获得更高的负载增加限制时,它将失败。
查看我的服务器上的postgresql日志,我得到以下信息:
CEST FATAL: connection to client lost
CEST LOG: could not receive data from client: An existing connection was forcibly closed by the remote host.在我的节点应用程序中使用npm pg@8.0.3或任何其他版本执行相同的查询,我会得到相同的问题,在较少的数据上成功地响应,而当它无法获取更多的行时:
Error: read ECONNRESET
at TCP.onStreamRead (internal/stream_base_commons.js:209:20) {
errno: -104,
code: 'ECONNRESET',
syscall: 'read'
}在访问这些查询时,我还在客户端机器上转储了一些wireshark pcap,并注意到当我收到错误时,wireshark日志如下所示:
3301 2.220496557 25.67.20.168 25.20.186.130 TCP 68 [TCP Dup ACK 2839#1] 45208 → 5432 [ACK] Seq=27 Ack=1 Win=64542 Len=0 SLE=2729 SRE=3143我对wireshark和网络问题知之甚少,但它看上去是关于重复确认"TCP“问题的。
所有这些都更加复杂,因为我只在一个linux (ubuntu)客户机上解决了这个问题,而其他客户机工作正常,没有任何问题,其中大约有10个是windows/linux-ubuntu混合的。
这很可能是一些网络问题,我想。
如果有任何线索我会很感激的。
发布于 2022-05-05 10:53:08
如果客户机和服务器都认为另一端挂起了它们,那么这显然是一个网络问题。
您不需要告诉我们这些查询需要多长时间,但是您可能会在某个介于网络组件之间的组件中触发超时,从而决定终止这个看似空闲的连接(有些人不知道除了HTTP之外还有其他协议)。您可以通过在服务器上设置tcp_keepalives_idle来防止这种情况。这里是关于这个主题的更多内容。
这可能是一个不同的问题,但这肯定是一个网络问题。
https://stackoverflow.com/questions/72118734
复制相似问题