[SERVER-44414] failCommand fail point does not work for ismaster Created: 04/Nov/19  Updated: 17/Dec/19  Resolved: 17/Dec/19

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Oleg Pudeyev (Inactive) Assignee: Benjamin Caimano (Inactive)
Resolution: Duplicate Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-45202 Improve Command alias infrastructure Closed
Operating System: ALL
Sprint: Service Arch 2019-12-16, Service Arch 2019-12-30
Participants:

 Description   

If I set the fail point on isMaster, it works:

ruby-driver-rs:SECONDARY> db.adminCommand({configureFailPoint:'failCommand',data:{failCommands:['isMaster'],closeConnection:true},mode:{times:1}})
{
	"ok" : 1,
	"$clusterTime" : {
		"clusterTime" : Timestamp(1572910119, 1),
		"signature" : {
			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
			"keyId" : NumberLong(0)
		}
	},
	"operationTime" : Timestamp(1572910119, 1)
}
ruby-driver-rs:SECONDARY> db.runCommand({isMaster:1})
2019-11-04T18:28:51.464-0500 E QUERY    [thread1] Error: error doing query: failed: network error while attempting to run command 'isMaster' on host '127.0.0.1:14420'  :
DB.prototype.runCommand@src/mongo/shell/db.js:168:1
@(shell):1:1
2019-11-04T18:28:51.465-0500 I NETWORK  [thread1] trying reconnect to 127.0.0.1:14420 (127.0.0.1) failed
2019-11-04T18:28:51.466-0500 I NETWORK  [thread1] reconnect 127.0.0.1:14420 (127.0.0.1) ok

If I set the same fail point on ismaster, it does not work:

ruby-driver-rs:SECONDARY> db.adminCommand({configureFailPoint:'failCommand',data:{failCommands:['ismaster'],closeConnection:true},mode:{times:1}})
{
	"ok" : 1,
	"$clusterTime" : {
		"clusterTime" : Timestamp(1572910209, 1),
		"signature" : {
			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
			"keyId" : NumberLong(0)
		}
	},
	"operationTime" : Timestamp(1572910209, 1)
}
ruby-driver-rs:SECONDARY> db.runCommand({ismaster:1})
{
	"hosts" : [
		"localhost:14420",
		"localhost:14421",
		"localhost:14422"
	],
	"setName" : "ruby-driver-rs",
	"setVersion" : 19,
	"ismaster" : false,
	"secondary" : true,
	"primary" : "localhost:14421",
	"me" : "localhost:14420",
	"lastWrite" : {
		"opTime" : {
			"ts" : Timestamp(1572910209, 1),
			"t" : NumberLong(8)
		},
		"lastWriteDate" : ISODate("2019-11-04T23:30:09Z"),
		"majorityOpTime" : {
			"ts" : Timestamp(1572910209, 1),
			"t" : NumberLong(8)
		},
		"majorityWriteDate" : ISODate("2019-11-04T23:30:09Z")
	},
	"maxBsonObjectSize" : 16777216,
	"maxMessageSizeBytes" : 48000000,
	"maxWriteBatchSize" : 100000,
	"localTime" : ISODate("2019-11-04T23:30:19.453Z"),
	"logicalSessionTimeoutMinutes" : 30,
	"connectionId" : 6745,
	"minWireVersion" : 0,
	"maxWireVersion" : 8,
	"readOnly" : false,
	"ok" : 1,
	"$clusterTime" : {
		"clusterTime" : Timestamp(1572910209, 1),
		"signature" : {
			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
			"keyId" : NumberLong(0)
		}
	},
	"operationTime" : Timestamp(1572910209, 1)
}
ruby-driver-rs:SECONDARY> 

Since "ismaster: 1" is a recognized command, I expect a fail point set on "ismaster" to affect "ismaster: 1" command.

Although I personally strive to use consistent case, it will probably be better user experience if fail point on isMaster triggered on ismaster and vice versa.

2019-09-13T16:46:56.464-0400 I CONTROL [initandlisten] ** NOTE: This is a development version (4.3.0-574-g6e02a4d) of MongoDB.



 Comments   
Comment by Benjamin Caimano (Inactive) [ 06/Dec/19 ]

This isn't especially surprising. failCommand evaluates a string. That string is always Command::getName() which is not the "oldName" which we only use when registering the command. This seems like a reasonable feature with two concerns:

  • shouldActivateFailCommand() should take a const CommandInvocation* instead of a string. No need to throw away information.
  • Command should be aware of its oldName. CommandInvocation should be aware of which variant it was called with. We should probably switch to "canonicalName" and "aliases" because the concept is simple and useful.
Generated at Thu Feb 08 05:05:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.