...
BugZero found this defect 2724 days ago.
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
asya commented on Tue, 30 Oct 2018 19:14:45 +0000: 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). asya commented on Tue, 30 Oct 2018 19:08:42 +0000: Note that the shell correctly routes explain of update command to the primary, so findAndModify seems to be a bug. asya commented on Tue, 30 Oct 2018 19:07:34 +0000: 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. asya commented on Tue, 30 Oct 2018 18:01:59 +0000: misha.tyulenev I could not reproduce sending findAndModify command to secondary via the shell. Only 'explain' fails. misha.tyulenev commented on Thu, 3 Aug 2017 17:01:32 +0000: 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. ian@10gen.com commented on Thu, 3 Aug 2017 14:45:37 +0000: Explain of write commands on secondaries is supposed to fail.