[SERVER-53859] Add queryHash to the mongos slow query logs Created: 18/Jan/21  Updated: 29/Oct/23  Resolved: 07/Jul/21

Status: Closed
Project: Core Server
Component/s: Logging
Affects Version/s: 4.4.1
Fix Version/s: 5.1.0-rc0

Type: Improvement Priority: Minor - P4
Reporter: Ankit Shah Assignee: Mickey Winters
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Documented
is documented by DOCS-14762 Investigate changes in SERVER-53859: ... Closed
Related
is related to SERVER-57404 add queryHash to mongos slow query lo... Backlog
is related to SERVER-57406 add queryHash and planCacheKey to mon... Backlog
is related to SERVER-57405 add queryHash and planCacheKey to mon... Closed
Backwards Compatibility: Fully Compatible
Sprint: Query Execution 2021-05-31, Query Execution 2021-06-14, Query Execution 2021-06-28, Query Execution 2021-07-12
Participants:
Case:

 Description   

`queryHash` field introduced in slow query logs in v4.2 is available only in `mongod` logs and not in `mongos` logs. The documentation does not have any mention of relevant behaviour. Is this expected or requires any configuration change? 

Sample mongos slow query log:

{"t":{"$date":"2020-12-31T02:19:33.680+00:00"},"s":"I",  "c":"COMMAND",  "id":51803,   "ctx":"conn128","msg":"Slow query","attr":{"type":"command","ns":"xxxx.companyPriority","command":{"find":"companyPriority","filter":{"_id":{"$in":[{"$oid":"5319df10e4b0f7e16602a313"}]}},"$db":"xxxx","$clusterTime":{"clusterTime":{"$timestamp":{"t":1609381171,"i":2}},"signature":{"hash":{"$binary":{"base64":"C2cNRe4vAhiBs97T6VYXIYYU1Ck=","subType":"0"}},"keyId":6877905033757720578}},"lsid":{"id":{"$uuid":"ba72a15f-2568-43e9-8c9a-abd7bd2aa6be"}}},"nShards":1,"cursorExhausted":true,"numYields":0,"nreturned":1,"reslen":278,"protocol":"op_msg","durationMillis":2007}}



 Comments   
Comment by Githook User [ 07/Jul/21 ]

Author:

{'name': 'Mickey. J Winters', 'email': 'mickey.winters@mongodb.com', 'username': 'mjrb'}

Message: SERVER-53859 Add queryHash to the mongos slow query logs
Branch: master
https://github.com/mongodb/mongo/commit/a862b5d0279bb681634f698def16b90c1117b3f5

Comment by Ankit Shah [ 23/Jun/21 ]

@Mickey Winters That will be fine for my use case. With this implementation, for a given query shape I will have (no. of shards + no. of mongos) queryHashes, which should be manageable. Thanks.

Comment by Mickey Winters [ 10/Jun/21 ]

Hey ankit.shah.sm@gmail.com I've been working on this ticket recently. One thing I wanted to point out is that the queryHash is not guaranteed to be the same if you are cross referencing between mongod and mongos. However, It can still be useful for grouping slow queries by shape in the mongos log. Does this help you with your use case?

Comment by David Storch [ 03/Feb/21 ]

Hi ankit.shah.sm@gmail.com! This behavior is by design, but it is definitely something that would be nice to add in the future. I am going to convert this ticket to type "Improvement" rather than "Bug" and retitle it accordingly. I am going to add this ticket back to our triage queue so we can decide on its priority.

The reason that the "queryHash" field does not appear on mongos is that its implementation is currently tied to the plan cache, and plan caching currently takes place on mongod. However, unlike the "planCacheKey", the "queryHash" is not inherently tied to the plan cache and we could definitely introduce it in the mongos logs as well.

Comment by Ratika Gandhi [ 29/Jan/21 ]

cc. craig.homa

Comment by Edwin Zhou [ 25/Jan/21 ]

Hi ankit.shah.sm@gmail.com,

Thanks for your ticket! I can understand why you'd like to see the queryHash in a mongos slow log. I'll pass this along to the appropriate team.

Best,
Edwin

Generated at Thu Feb 08 05:32:03 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.