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

Remove DBDirectClient class

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Internal Code
    • None
    • Storage Execution

      The DBDirectClient class is an implementation of DBClientBase that simply calls the server's message handling code. It provides a unified API (the DBClientBase API) for performing "sub-operations", and is often used as a simple way for a command implementation to perform some subtask.

      Use of DBDirectClient is generally considered harmful for a number of reasons, including that it:

      • Subverts the API of the subsystem being called into, and introduces a large number of dependencies for the calling subsystem
      • Introduces performance overhead through unnecessary message creation and message parsing
      • Prevents yielding of locks during execution of the sub-operation, when the calling operation is already holding a lock
      • Is hard for new developers to understand
      • Has (historically) been a reliable source of bugs

      As of version ~3.1.0 of the server, the following lists all current uses of DBDirectClient in the server. They are roughly ordered in decreasing order of difficulty to remove.

      • V8Scope: provides connection objects for the eval command (e.g. the connection object associated with the "db" variable)
      • dbtests/: various uses for testing
      • Cloner: provides implementation of "copydb" within same host
      • MapReduceCommand: miscellaneous collection admin tasks (drop/count/renameCollection/splitVector), reading documents for reduce post-processing
      • DocumentSourceOut: agg $out miscellaneous collection admin tasks (create/listIndexes/createIndexes/renameCollection), inserting documents into $out collection
      • AuthzManagerExternalState: CRUD operations (with write concern) on "system.users" collection
      • DocumentSourceGeoNear: generates documents for $geoNear agg operator
      • Trivial uses in ApplyOpsCmd, CmdFileMD5, ReplSource, initOpTimeFromOplog(), checkIfReplMissingFromCommandLine()

            Assignee:
            backlog-server-execution [DO NOT USE] Backlog - Storage Execution Team
            Reporter:
            rassi J Rassi
            Votes:
            2 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated:
              Resolved: