Mongodb V4.2 has introduced queryHash in slow query logs to identify slow queries with same query shape. While this queryHash
is available in slow query logs in mongod
logs (shard server), it is not present in any of the slow query logs on my mongos
server.
Mongod log
{"t":{"$date":"2021-01-09T01:45:27.821+00:00"},"s":"I", "c":"COMMAND", "id":51803, "ctx":"conn143447","msg":"Slow query","attr":{"type":"command","ns":"xxxx.collection","command":{"find":"collection","filter":{"entityId":"xxxx.ru"},"projection":{"crawlerDataId":0},"sort":{"sourceUpdatedAt":-1},"readConcern":{"provenance":"implicitDefault"},"limit":100,"runtimeConstants":{"localNow":{"$date":"2021-01-09T01:45:27.689Z"},"clusterTime":{"$timestamp":{"t":1610156727,"i":93}}},"_use44SortKeys":true,"shardVersion":[{"$timestamp":{"t":89277,"i":1}},{"$oid":"5cb57c9eafd72c1e06b5c433"}],"clientOperationKey":{"$uuid":"56e5a665-9162-4e1d-a368-165e592d59de"},"lsid":{"id":{"$uuid":"a15a9b9c-bb4f-4d1f-8770-08b64b28ad2b"},"uid":{"$binary":{"base64":"6ikS+z/HSNSwWB1ARioMqqzdlxOaNtFe+gViCoYwELs=","subType":"0"}}},"$clusterTime":{"clusterTime":{"$timestamp":{"t":1610156727,"i":93}},"signature":{"hash":{"$binary":{"base64":"7GLR2+4NQu2cWHpgqx31zmi28NE=","subType":"0"}},"keyId":6875251194940358707}},"$audit":{"$impersonatedUsers":[{"user":"xxxx","db":"xxxx"}],"$impersonatedRoles":[{"role":"readWrite","db":"xxxx"}]},"$client":{"driver":{"name":"mongo-java-driver","version":"3.9.1"},"os":{"type":"Linux","name":"Linux","architecture":"amd64","version":"5.4.0-1021-aws"},"platform":"Java/Private Build/1.8.0_265-8u265-b01-0ubuntu2~20.04-b01","mongos":{"host":"xxxx:27017","client":"xxxxx","version":"4.4.1"}},"$configServerState":{"opTime":{"ts":{"$timestamp":{"t":1610156725,"i":79}},"t":12}},"$db":"xxxx"},"planSummary":"IXSCAN { entityId: \"hashed\" }","keysExamined":73,"docsExamined":73,"hasSortStage":true,"cursorExhausted":true,"numYields":8,"nreturned":73,"queryHash":"F305D754","planCacheKey":"42D383C3","reslen":397160,"locks":{"ReplicationStateTransition":{"acquireCount":{"w":9}},"Global":{"acquireCount":{"r":9}},"Database":{"acquireCount":{"r":9}},"Collection":{"acquireCount":{"r":9}},"Mutex":{"acquireCount":{"r":3}}},"readConcern":{},"storage":{"data":{"bytesRead":5215788,"timeReadingMicros":129685}},"protocol":"op_msg","durationMillis":132}}
Mongos 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}}
"queryHash":"F305D754"
is present in mongod
log and no queryHash
key in mongos
The documentation nowhere mentions about the queryHash
availability (or the absence of it) on mongos
server logs separately. Is this expected behaviour or some configuration changes are required to get queryHash
in mongos
logs?
Note: mongos
and mongod
both are running on version 4.4.1