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

Allow failCommand failpoint to trigger only on a specific MongoClient

    • Type: Icon: New Feature New Feature
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.4.0-rc2, 4.2.9, 4.7.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Fully Compatible
    • v4.4, v4.2
    • Service arch 2020-04-20

      For streamable isMaster, drivers would like to add tests that fail isMaster commands, like this:

      db.adminCommand({"configureFailpoint": "failCommand", "mode": {"times": 2}, "data": {"failCommands": ["isMaster"], "errorCode": 94, "closeConnection": false}})


      db.adminCommand({"configureFailpoint": "failCommand", "mode": "alwaysOn", "data": {"failCommands": ["isMaster"], "errorCode": 94, "closeConnection": false}})

      However, failing isMaster with failCommand is tricky because:

      1. driver tests often have 1 (or more) MongoClients running in the background of the test suite. These clients will likely trigger the failpoint in addition to the MongoClient we want to test.
      2. using "mode": "alwaysOn" makes it impossible for a driver to re-discover the server after it is marked Unknown because SDAM discovery depends on a successful isMaster. This means it may not be possible to disable the "alwaysOn" failpoint without other workarounds. (A driver needs to reserve a connection in order to disable the failpoint and/or ensure that the node is still selectable.)

      It would be great if the failCommand failpoint was able to filter which clients trigger the failure.

      One proposal to fix these issues would be to implement an "appName" filter on the failCommand failpoint. "appName" would work similar to the "threadName" (SERVER-38054) feature but instead of the individual connection name (eg "conn8") we'd use the "appName" from the connection handshake. This would allow driver tests to control which clients trigger a failpoint:

      db.adminCommand({"configureFailpoint": "failCommand", "mode": "alwaysOn", "data": {"failCommands": ["isMaster"], "errorCode": 94, "closeConnection": false, "appName": "failingIsMasterTest"}})
      # Only this client will trigger the failpoint
      client = MongoClient(appName="failingIsMasterTest")

            spencer@mongodb.com Spencer Brody (Inactive)
            shane.harvey@mongodb.com Shane Harvey
            1 Vote for this issue
            9 Start watching this issue