[SERVER-47195] Allow failCommand failpoint to trigger only on a specific MongoClient Created: 30/Mar/20  Updated: 08/Jan/24  Resolved: 07/Apr/20

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 4.4.0-rc2, 4.2.9, 4.7.0

Type: New Feature Priority: Major - P3
Reporter: Shane Harvey Assignee: Spencer Brody (Inactive)
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Related
Backwards Compatibility: Fully Compatible
Backport Requested:
v4.4, v4.2
Sprint: Service arch 2020-04-20
Participants:

 Description   

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}})

And:

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")



 Comments   
Comment by Githook User [ 17/Jun/20 ]

Author:

{'name': 'Spencer T Brody', 'email': 'spencer@10gen.com', 'username': 'stbrody'}

Message: SERVER-47195 Allow configuring failCommand failpoint to activate only for a given appName

(cherry picked from commit 2b742ad3d0fbf0238c32e6cd3b5842fb5bee77b9)
Branch: v4.2
https://github.com/mongodb/mongo/commit/3fb2879e87eeaffbd0d2f093268f3ac2f93ab332

Comment by Spencer Brody (Inactive) [ 12/May/20 ]

Requesting backport to 4.2

Comment by Jeffrey Yemin [ 12/May/20 ]

spencer any change for a 4.2 backport of this failpoint improvement? It would really help us to add pre-streamable ismaster integration tests in drivers if we had this is 4.2.

CC shane.harvey

Comment by Githook User [ 13/Apr/20 ]

Author:

{'name': 'Spencer T Brody', 'email': 'spencer@10gen.com', 'username': 'stbrody'}

Message: SERVER-47195 Allow configuring failCommand failpoint to activate only for a given appName

(cherry picked from commit 021db11a119f431d25afef650735cbf61a823a40)
Branch: v4.4
https://github.com/mongodb/mongo/commit/2b742ad3d0fbf0238c32e6cd3b5842fb5bee77b9

Comment by Githook User [ 07/Apr/20 ]

Author:

{'name': 'Spencer T Brody', 'email': 'spencer@10gen.com', 'username': 'stbrody'}

Message: SERVER-47195 Allow configuring failCommand failpoint to activate only for a given appName
Branch: master
https://github.com/mongodb/mongo/commit/021db11a119f431d25afef650735cbf61a823a40

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