[SERVER-20810] Find command errors should not include a stack trace Created: 07/Oct/15  Updated: 15/Oct/15  Resolved: 09/Oct/15

Status: Closed
Project: Core Server
Component/s: Querying, Shell
Affects Version/s: 3.1.9
Fix Version/s: 3.2.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Andy Schwerin Assignee: David Storch
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: QuInt A (10/12/15)
Participants:

 Description   

Here is an example command an error in the 3.1.9 shell when it is configured to use find command:

mongos> db.messages.find({},{_id:0,'headers.From':1,'headers.Subject':1,'headers.Date':1}).batchSize(10);
assert: command failed: {
	"ok" : 0,
	"errmsg" : "Retried 10 times without establishing shard version on a reachable host.",
	"code" : 63
} : undefined
_getErrorWithCode@src/mongo/shell/utils.js:23:13
doassert@src/mongo/shell/assert.js:13:14
assert.commandWorked@src/mongo/shell/assert.js:259:5
DBCommandCursor@src/mongo/shell/query.js:657:5
DBQuery.prototype._exec@src/mongo/shell/query.js:103:28
DBQuery.prototype.hasNext@src/mongo/shell/query.js:257:5
DBQuery.prototype.shellPrint@src/mongo/shell/query.js:500:17
shellPrintHelper@src/mongo/shell/utils.js:444:1
@(shell2):1:1
 
Error: command failed: {
	"ok" : 0,
	"errmsg" : "Retried 10 times without establishing shard version on a reachable host.",
	"code" : 63
} : undefined

And here is what you get with the 3.0.6 shell or the 3.1.9 shell with wire protocol find:

mongos> db.messages.find({},{_id:0,'headers.From':1,'headers.Subject':1,'headers.Date':1}).batchSize(10);
Error: error: {
	"$err" : "Retried 10 times without establishing shard version on a reachable host.",
	"code" : 63
}



 Comments   
Comment by Githook User [ 09/Oct/15 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-20810 better error when find, getMore, or killCursors commands issued by DBQuery fail
Branch: master
https://github.com/mongodb/mongo/commit/0968278f0254c5e636946811e2f5f2dd326c59df

Comment by Andy Schwerin [ 09/Oct/15 ]

Checkout _getErrorWithCode(codeOrObj, message) used by doassert. It's got a pretty weird signature, but shows how asserts generate instances of Error.

Comment by Andy Schwerin [ 09/Oct/15 ]

No, the purpose was to get rid of the stack trace.

On Fri, Oct 9, 2015, 12:32 AM Max Hirschhorn (JIRA) <jira@mongodb.org>

Comment by Githook User [ 09/Oct/15 ]

Author:

{u'username': u'visemet', u'name': u'Max Hirschhorn', u'email': u'max.hirschhorn@mongodb.com'}

Message: Revert "SERVER-20810 better error text when find, getMore, or killCursors commands issued by DBQuery fail"

This reverts commit 1b7f8319e1115bdaca3ad48c986846065db13569.
Branch: master
https://github.com/mongodb/mongo/commit/d07615da82aabf70f9ff086eeed2571c49680aaa

Comment by Max Hirschhorn [ 09/Oct/15 ]

The jstests/sharding/replset_config/bad_config_load.js test depends on the presence of a "code" property on the Error object.

// Make sure we get a transport error, and not a no-primary error
assert(e.code == 10276 ||       // Transport error
       e.code == 13328 ||       // Connect error
       e.code == 13639 ||       // Connect error to replSet primary
       e.code == ErrorCodes.HostUnreachable ||
       e.code == ErrorCodes.NotMaster ||
       e.code == ErrorCodes.FailedToSatisfyReadPreference);

If this ticket is meant to undo the work of SERVER-19493 and SERVER-20154 for including additional information in the Error object, then tests that were depending on this behavior for find commands need to be updated.

[js_test:bad_config_load] 2015-10-08T23:31:35.504+0000 Error: { "ok" : 0, "errmsg" : "Connection reset by peer", "code" : 6 }
...
[js_test:bad_config_load] 2015-10-08T23:31:35.505+0000 2015-10-08T23:31:35.504+0000 E QUERY    [thread1] Error: assert failed :
[js_test:bad_config_load] 2015-10-08T23:31:35.505+0000 doassert@src/mongo/shell/assert.js:15:14
[js_test:bad_config_load] 2015-10-08T23:31:35.505+0000 assert@src/mongo/shell/assert.js:25:5
[js_test:bad_config_load] 2015-10-08T23:31:35.505+0000 @jstests/sharding/replset_config/bad_config_load.js:43:9
[js_test:bad_config_load] 2015-10-08T23:31:35.505+0000
[js_test:bad_config_load] 2015-10-08T23:31:35.505+0000 failed to load: jstests/sharding/replset_config/bad_config_load.js

Comment by Githook User [ 08/Oct/15 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-20810 better error text when find, getMore, or killCursors commands issued by DBQuery fail
Branch: master
https://github.com/mongodb/mongo/commit/1b7f8319e1115bdaca3ad48c986846065db13569

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