[SERVER-30466] shell should not inject $readPreference{"secondary"} for explain for findAndModify Created: 01/Aug/17  Updated: 06/Dec/22

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

Type: Bug Priority: Minor - P4
Reporter: Misha Tyulenev Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 0
Labels: open_todo_in_code, query-44-grooming
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-30650 mongo shell adds readPreference to f... Closed
Assigned Teams:
Query Optimization
Operating System: ALL
Participants:

 Description   

js_test:index_partial_read_ops] 2017-08-01T17:15:38.810+0000 }
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.810+0000 XXX Calling runCommand for cmd: {
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.810+0000 	"query" : {
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.810+0000 		"explain" : {
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.810+0000 			"findAndModify" : "index_partial_read_ops",
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.810+0000 			"query" : {
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.810+0000 				"x" : {
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.810+0000 					"$gt" : 1
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.810+0000 				},
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.811+0000 				"a" : 1
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.811+0000 			},
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.811+0000 			"update" : {
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.811+0000 				"$inc" : {
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.811+0000 					"x" : 1
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.811+0000 				}
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.811+0000 			}
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.811+0000 		},
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.811+0000 		"verbosity" : "executionStats"
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.811+0000 	},
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.811+0000 	"$readPreference" : {
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.811+0000 		"mode" : "secondary"
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.811+0000 	},
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.812+0000 	"$clusterTime" : {
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.812+0000 		"clusterTime" : Timestamp(1501607738, 6),
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.812+0000 		"signature" : {
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.812+0000 			"hash" : BinData(0,"xb3GEt3OVglybQfgdX6R+luXVzA="),
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.812+0000 			"keyId" : NumberLong("6449356074590928897")
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.812+0000 		}
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.812+0000 	}
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.812+0000 }
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.812+0000 XXX runCommandWith recieved: {
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.812+0000 	"ok" : 0,
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.813+0000 	"errmsg" : "Explain for findAndModify failed: { ok: 0.0, errmsg: \"Explain's child command cannot run on this node. Are you explaining a write command on a secondary?\" }",
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.813+0000 	"code" : 96,
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.813+0000 	"codeName" : "OperationFailed",
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.813+0000 	"$clusterTime" : {
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.813+0000 		"clusterTime" : Timestamp(1501607738, 6),
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.813+0000 		"signature" : {
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.813+0000 			"hash" : BinData(0,"xb3GEt3OVglybQfgdX6R+luXVzA="),
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.813+0000 			"keyId" : NumberLong("6449356074590928897")
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.813+0000 		}
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.814+0000 	},
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.814+0000 	"operationTime" : Timestamp(1501607738, 6)
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.814+0000 }
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.814+0000 2017-08-01T17:15:38.609+0000 E QUERY    [thread1] Error: explain failed: {
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.814+0000 	"ok" : 0,
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.814+0000 	"errmsg" : "Explain for findAndModify failed: { ok: 0.0, errmsg: \"Explain's child command cannot run on this node. Are you explaining a write command on a secondary?\" }",
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.814+0000 	"code" : 96,
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.814+0000 	"codeName" : "OperationFailed",
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.815+0000 	"$clusterTime" : {
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.815+0000 		"clusterTime" : Timestamp(1501607738, 6),
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.815+0000 		"signature" : {
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.815+0000 			"hash" : BinData(0,"xb3GEt3OVglybQfgdX6R+luXVzA="),
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.815+0000 			"keyId" : NumberLong("6449356074590928897")
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.815+0000 		}
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.815+0000 	},
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.815+0000 	"operationTime" : Timestamp(1501607738, 6)
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.815+0000 } :
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.815+0000 _getErrorWithCode@src/mongo/shell/utils.js:25:13
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.816+0000 throwOrReturn@src/mongo/shell/explainable.js:31:1
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.816+0000 constructor/this.findAndModify@src/mongo/shell/explainable.js:144:20
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.816+0000 @jstests/core/index_partial_read_ops.js:72:15
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.816+0000 @jstests/core/index_partial_read_ops.js:10:2
[js_test:index_partial_read_ops] 2017-08-01T17:15:38.816+0000 failed to load: jstests/core/index_partial_read_ops.js



 Comments   
Comment by Asya Kamsky [ 30/Oct/18 ]

Note that the shell has the same problem for aggregate with $out which it correctly sends to primary regardless of read preference specified on connection, but explain for it still goes to secondary (giving an error).

Comment by Asya Kamsky [ 30/Oct/18 ]

Note that the shell correctly routes explain of update command to the primary, so findAndModify seems to be a bug.

Comment by Asya Kamsky [ 30/Oct/18 ]

Looks like the confusion was the other ticket that was closed as dup.

shell in fact correctly detects that findAndModify is a write command and sends it to primary, however explain on findAndModify honors readPreference secondary which is inconsistent.

I believe this is a bug in the shell that should be fixed.

 

Comment by Asya Kamsky [ 30/Oct/18 ]

misha.tyulenev I could not reproduce sending findAndModify command to secondary via the shell.

Only 'explain' fails.

 

Comment by Misha Tyulenev [ 03/Aug/17 ]

david.storch This issue is that the mongo shell does not detect that findAndModify is a write command and sends it to secondary. The fix should be done in the shell code.

Comment by Ian Whalen (Inactive) [ 03/Aug/17 ]

Explain of write commands on secondaries is supposed to fail.

Generated at Thu Feb 08 04:23:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.