为什么“你好” (ISMASTER)带有拓扑交换的命令?
要复制我在生产中看到的内容,我在本地运行一个独立的mongodb实例,其中hello()
admin> admin命令(以前ismaster
)运行直到Maxawaittimems
and Times Out,每次:
db.runCommand({
"hello": 1,
"topologyVersion": {
"processId": ObjectId("628c762af984c948c15f8811"),
"counter": NumberLong(0)
},
"maxAwaitTimeMS": 5000,
"$db": "admin"
});;
请注意,当'Time Unding'时,响应仍然是客户所期望的 - 尚不清楚Mongo Server不会立即使用此响应,而不是具有查询必须运行,直到其maxawaittimems
响应之前:
{
"isWritablePrimary" : true,
"topologyVersion" : {
"processId" : ObjectId("628c762af984c948c15f8811"),
"counter" : 0
},
"maxBsonObjectSize" : 16777216,
"maxMessageSizeBytes" : 48000000,
"maxWriteBatchSize" : 100000,
"localTime" : ISODate("2022-05-29T11:35:36.011+01:00"),
"logicalSessionTimeoutMinutes" : 30,
"connectionId" : 86043,
"minWireVersion" : 0,
"maxWireVersion" : 9,
"readOnly" : false,
"ok" : 1
}
服务器上没有其他活动 - 因此,否则将其持有性能或连接的问题。即使增加到5分钟,查询将只需“等待玛特ximems”。 问题仅在呼叫中包含topologyversion
的情况
// query completes immediately
db.runCommand({
"hello": 1,
"$db": "admin"
});
// and the response includes the following:
// { "processId" : ObjectId("628c762af984c948c15f8811") }
此 Mongo驱动程序(Pymongo和Ruby Mongo),我们在生产Mongo实例上看到了相同的问题 - CurrentOp
都显示了许多Hello> Hello()
查询,所有这些正在计时。
我的问题是,
除了它在currentop
list中产生的噪声外, 这些请求为什么要按预期进行计时并且不会立即完成?秒)以及理解原因的好奇心,我也希望解决这个问题,以帮助确保由于这个问题而无法建立联系。减少maxawaittimems
(假设Mongo驱动程序给出这样的控制)会感觉隐藏问题。在复制的MongoDB服务器上执行一些测试时,这个问题似乎并没有发生。
To replicate what I’m seeing on Production, I have a standalone MongoDB instance running locally, where the hello()
admin command (previously isMaster
) runs till the maxAwaitTimeMS
and times out, every time:
db.runCommand({
"hello": 1,
"topologyVersion": {
"processId": ObjectId("628c762af984c948c15f8811"),
"counter": NumberLong(0)
},
"maxAwaitTimeMS": 5000,
"$db": "admin"
});;
Note that when 'timing out', the response is still what the client would have expected - what's not clear is why the Mongo server does not return with this immediately, rather than having the query have to run till its maxAwaitTimeMS
before responding:
{
"isWritablePrimary" : true,
"topologyVersion" : {
"processId" : ObjectId("628c762af984c948c15f8811"),
"counter" : 0
},
"maxBsonObjectSize" : 16777216,
"maxMessageSizeBytes" : 48000000,
"maxWriteBatchSize" : 100000,
"localTime" : ISODate("2022-05-29T11:35:36.011+01:00"),
"logicalSessionTimeoutMinutes" : 30,
"connectionId" : 86043,
"minWireVersion" : 0,
"maxWireVersion" : 9,
"readOnly" : false,
"ok" : 1
}
There is no other activity on the server - so it's not an issue of performance or connections otherwise being held up. The query will run as long as the ‘awaitMaxTimeMS’, even when increased to e.g 5 minutes. The issue only occurs where the topologyVersion
is included in the call, specifically when using the correct processID
that is returned when first running the query as follows:
// query completes immediately
db.runCommand({
"hello": 1,
"$db": "admin"
});
// and the response includes the following:
// { "processId" : ObjectId("628c762af984c948c15f8811") }
These calls are being made from Mongo drivers (PyMongo and Ruby Mongo), and we are seeing the same issue on a Production Mongo instance - where currentOp
is showing many of these hello()
queries, all of which are timing out.
My question is, why are these requests timing out and not completing immediately as expected?
Aside from the noise it creates in the currentOp
list (with each query hanging around for the 10 seconds) and the curiosity in understanding why, I'd also like this resolved as to help ensure connections aren't otherwise being held up due to this issue. Reducing the maxAwaitTimeMS
(assuming the Mongo drivers give such control) would feel like hiding the issue. The issue does not seem to be happening while performing a few tests on a replicated MongoDB server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个“特殊”模式的“特殊”模式的预期行为,称为Hello线程。用2个单词,客户端仅通过发送Hello命令来启动流服务器的状态,然后等待服务器的响应(而无需发送请求)。因此,
maxawaittimems
是一个最大时间,服务器可以等待,然后再向客户端发送响应。是的,这是预期的。等待可能小于
maxawaittimems
,例如,如果在等待期间更改了服务器拓扑,但是此值设置了顶部等待界限,如果服务器健康,则您将等待整个指定的期间我明白了,所以您是说让许多ismaster/Hello查询都是正常的behaivour ,如果同时发生的话, ,那么我会投票认为它们在
me
中包含不同的端点。响应中的字段,因为驱动程序为每个端点创建一个单独的Hello
线程this is expected behavior for a "special" mode for a hello thread called streaming. In 2 words, a client just initiates streaming server's states by sending a hello command and then waits responses from server (without sending requests). So
maxAwaitTimeMS
is a max time which server can wait before sending response to the client.So yes, it's expected. Waiting can be less than
maxAwaitTimeMS
, for example if server topology has been changed during waiting, but this value sets the top waiting bound and if the server is healthy, you will wait the whole specified periodif it happens at the same time, then I would vote that they contain different endpoints in
me
field in the response since driver creates a separatehello
thread for each endpoint