[SERVER-58337] Log deprecation warning and bump serverStatus counter upon receipt of OP_QUERY command Created: 07/Jul/21  Updated: 29/Oct/23  Resolved: 09/Jul/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.1.0-rc0, 5.0.9

Type: Task Priority: Major - P3
Reporter: David Storch Assignee: Irina Yatsenko (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
is depended on by SERVER-58338 Return an error if client attempts an... Closed
Documented
Backwards Compatibility: Fully Compatible
Backport Requested:
v5.0
Sprint: Query Execution 2021-07-12, Query Execution 2021-07-26
Participants:

 Description   

In 5.0, we deprecated OP_QUERY find operations. The deprecation is surfaced to the user through logging a warning with log id 5578800, as well as incrementing the db.serverStatus().opcounters.deprecated.query counter.

We also intended to deprecate OP_QUERY commands other than isMaster/hello (since OP_QUERY isMaster command is used for the connection handshake). However, unlike OP_QUERY find operations, OP_QUERY commands are currently not reflected in either the logs or serverStatus. The task for this ticket is to add this logging and to bump the serverStatus counters when either mongod or mongos receives an OP_QUERY command other than "isMaster" or "hello". This needs to happen at a fairly high level in the service entry point, before the OP_QUERY command is upconverted to look like an OP_MSG request.

As a quick example of this problem in practice, I connected to the server with a 4.4 shell, forcing the shell to use the OP_QUERY RPC protocol, and then ran a command:

➜  ./build/install/bin/mongo --rpcProtocols opQueryOnly
MongoDB shell version v4.4.6
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("6495ee03-5beb-408d-ae2c-86ddbea4b548") }
MongoDB server version: 5.0.0-alpha0
WARNING: shell and server versions do not match
MongoDB Enterprise > db.setLogLevel(1)
MongoDB Enterprise > db.runCommand({ping: 1})

The log line for the ping command indicates that the protocol used was "op_query":

{"t":{"$date":"2021-07-07T15:36:38.225-04:00"},"s":"I",  "c":"COMMAND",  "id":51803,   "ctx":"conn2","msg":"Slow query","attr":{"type":"command","ns":"test.$cmd","appName":"MongoDB Shell","command":{"ping":1,"lsid":{"id":{"$uuid":"6495ee03-5beb-408d-ae2c-86ddbea4b548"}},"$db":"test"},"numYields":0,"reslen":53,"locks":{},"remote":"127.0.0.1:47248","protocol":"op_query","durationMillis":0}}

However, I see no deprecation warning in the logs, and the serverStatus counter is not incremented.

We should backport this ticket to 5.0, since 5.0 is where the deprecation is first in effect. We can also consider backporting the opcounters portion of the change to even older branches, although this is not strictly required.



 Comments   
Comment by Githook User [ 04/May/22 ]

Author:

{'name': 'Irina Yatsenko', 'email': 'irina.yatsenko@mongodb.com', 'username': 'IrinaYatsenko'}

Message: SERVER-58337 Log and count as deprecated commands issued via OP_QUERY
Branch: v5.0
https://github.com/mongodb/mongo/commit/e8309b83c6d47d11ca746d371af229bb02520863

Comment by Vivian Ge (Inactive) [ 06/Oct/21 ]

Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it’s been triggered. For more active release information, please keep an eye on #server-release. Thank you!

Comment by Githook User [ 09/Jul/21 ]

Author:

{'name': 'Irina Yatsenko', 'email': 'irina.yatsenko@mongodb.com', 'username': 'IrinaYatsenko'}

Message: SERVER-58337 Log and count as deprecated commands issued via OP_QUERY

All commands, except isMaster and hello, that use OP_QUERY with $cmd namespace are now flagged as deprecated.
Branch: master
https://github.com/mongodb/mongo/commit/95b18771c85283900f7a992b7eda350b8a3d6067

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