Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-58337

Log deprecation warning and bump serverStatus counter upon receipt of OP_QUERY command

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.1.0-rc0, 5.0.9
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Fully Compatible
    • v5.0
    • Query Execution 2021-07-12, Query Execution 2021-07-26

      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://
      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":"","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.

            irina.yatsenko@mongodb.com Irina Yatsenko (Inactive)
            david.storch@mongodb.com David Storch
            0 Vote for this issue
            2 Start watching this issue