[SERVER-22588] "validate" command result is ambiguous/undefined for sharded collections Created: 11/Feb/16  Updated: 26/Apr/16  Resolved: 12/Apr/16

Status: Closed
Project: Core Server
Component/s: Diagnostics
Affects Version/s: 3.3.1
Fix Version/s: 3.3.5

Type: Bug Priority: Major - P3
Reporter: Robert Guo (Inactive) Assignee: Robert Guo (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Minor Change
Operating System: ALL
Sprint: TIG 12 (04/01/16), TIG 13 (04/22/16)
Participants:
Linked BF Score: 0

 Description   

When the validate command is run against a sharded collection that does not have a chunk on every shard, the shards without a chunk will report "ns not found" with {ok: 0} and no valid field. This causes the command to report without a valid field at the top level.

This result is ambiguous and the drivers do different things to determine if the result is valid or not. For example, pymongo would search for the keyword "valid" and defaults to invalid if not found. The shell, on the other hand, searches for the string "exception" or "corrupt" in the stringified response object and defaults to valid if not found. As a result, pymongo fails but the shell doesn't in this scenario.

example output:

mongos> db.runCommand({validate:"test"})
{
	"raw" : {
		"Roberts-MacBook-Pro-347.local:20000" : {
			"ns" : "test.test",
			"nrecords" : 1,
			"nIndexes" : 1,
			"keysPerIndex" : {
				"test.test.$_id_" : 1
			},
			"valid" : true,
			"warnings" : [
				"Some checks omitted for speed. use {full:true} option to do more thorough scan."
			],
			"errors" : [ ],
			"ok" : 1
		},
		"Roberts-MacBook-Pro-347.local:20001" : {
			"ok" : 0,
			"errmsg" : "ns not found"
		}
	},
	"ok" : 0,
	"errmsg" : "{ Roberts-MacBook-Pro-347.local:20001: \"ns not found\" }"
}



 Comments   
Comment by Githook User [ 12/Apr/16 ]

Author:

{u'username': u'guoyr', u'name': u'Robert Guo', u'email': u'robert.guo@10gen.com'}

Message: SERVER-22588 disable validate_collection.js in the last_stable_mongos suite
Branch: master
https://github.com/mongodb/mongo/commit/9c2e3c15fc7874ea610bad23d9cafe46b22b1cb5

Comment by Robert Guo (Inactive) [ 12/Apr/16 ]

Minor change - Previously, the response of validate() is different depending on whether you invoke it on mongod or mongos.

Now, validate() through mongos on an unsharded collection will respond in the same format as mongod. For validate() invoked on sharded collections, the response format is unchanged.

Comment by Githook User [ 12/Apr/16 ]

Author:

{u'username': u'guoyr', u'name': u'Robert Guo', u'email': u'robert.guo@10gen.com'}

Message: SERVER-22588 make validate command work in a sharded collection
Branch: master
https://github.com/mongodb/mongo/commit/81f0c5f7893385acf1368cc2f110777dfdbb39da

Comment by Githook User [ 12/Apr/16 ]

Author:

{u'username': u'IanWhalen', u'name': u'Ian Whalen', u'email': u'ian.whalen@gmail.com'}

Message: Revert "SERVER-22588 make validate command work in a sharded collection"

This reverts commit 3caa06819ab544bf9e88f4413c363a6439fe1998.
Branch: master
https://github.com/mongodb/mongo/commit/574a4910e189536215d3e3ab3c206dd44f1d699d

Comment by Githook User [ 12/Apr/16 ]

Author:

{u'username': u'guoyr', u'name': u'Robert Guo', u'email': u'robert.guo@10gen.com'}

Message: SERVER-22588 make validate command work in a sharded collection
Branch: master
https://github.com/mongodb/mongo/commit/3caa06819ab544bf9e88f4413c363a6439fe1998

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