简体   繁体   English

Mongo::Error::SocketError: Broken pipe 在 mongo 副本集中执行查询时

[英]Mongo::Error::SocketError: Broken pipe when executing queries in a mongo replica set

I randomly get this error from my rails app connected to a mongo replica set.我从连接到 mongo 副本集的 rails 应用程序中随机收到此错误。 This then leads to the server description getting changed to 'unknown' and server selection starting all over again.然后这会导致服务器描述更改为“未知”并且服务器选择重新开始。

This doesn't happen when I try running the app in local connected to a standalone mongod server.当我尝试在连接到独立 mongod 服务器的本地运行应用程序时,不会发生这种情况。

For some reason, connecting to a replica set and executing repeated queries on it results in出于某种原因,连接到副本集并对其执行重复查询会导致

Read retry due to: Mongo::Error::SocketError EOFError: end of file reached

Is this an issue with the underlining SSL/TLS connection to the replica set?这是与副本集的下划线 SSL/TLS 连接的问题吗? I've tried increasing the socket_timeout, connection_timeout in my mongoid.yml with no success.我尝试在我的 mongoid.yml 中增加 socket_timeout、connection_timeout 没有成功。

This happens when the server closes the connection to the client.当服务器关闭与客户端的连接时会发生这种情况。 One time when that happens is when a replica set has an election - the old primary closes all of its connections with MongoDB 4.0 and earlier (not with 4.2+).发生这种情况的一种情况是,当一个副本集进行选举时——旧的主节点关闭了它与 MongoDB 4.0 及更早版本(而不是 4.2+)的所有连接。

Since the read is retried, the situation does not generally affect the application other than the diagnostic message being printed that you see.由于重试读取,除了您看到的正在打印的诊断消息外,这种情况通常不会影响应用程序。

You can look into the server logs at the time when the message is printed to see why the server closed the connection.您可以在打印消息时查看服务器日志,以了解服务器关闭连接的原因。 Sometimes connections are closed without server-side logging (for example, when the server process terminates it doesn't log all connection closes).有时连接在没有服务器端日志记录的情况下关闭(例如,当服务器进程终止时,它不会记录所有连接关闭)。

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

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