[SERVER-4874] unrecognized command: setShardVersion Created: 04/Feb/12  Updated: 15/Aug/12  Resolved: 25/May/12

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

Type: Bug Priority: Major - P3
Reporter: Zac Witte Assignee: Randolph Tan
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubunutu 11.10 and 11.4, mongodb version 2.0.2 (all of mongod, mongos, and mongo client). Sharded 3 nodes, no replica sets, 3 config servers


Issue Links:
Duplicate
is duplicated by SERVER-5243 mongos will route getLastError comman... Closed
Operating System: Linux
Participants:

 Description   

I just set up a brand new shard cluster and received the following error when trying to create an index on a non-sharded collection. I tried the command multiple times and got the same error, but after I restart the mongo client the command worked.

ubuntu@mongo1:~/mongodb-linux-x86_64-2.0.2$ bin/mongo
MongoDB shell version: 2.0.2
connecting to: test
mongos> use pb2
switched to db pb2
mongos> db.adminCommand(

{addShard:"mongo1.foobar.com"}

)

{ "ok" : 0, "errmsg" : "can't add a mongos process as a shard" }

mongos> db.adminCommand(

{addShard:"mongo1.foobar.com:27018"}

)

{ "shardAdded" : "shard0000", "ok" : 1 }

mongos> db.adminCommand(

{addShard:"mongo2.foobar.com:27018"}

)

{ "shardAdded" : "shard0001", "ok" : 1 }

mongos> db.adminCommand(

{addShard:"mongo3.foobar.com:27018"}

)

{ "shardAdded" : "shard0002", "ok" : 1 }

mongos> db.adminCommand(

{enablesharding:'pb2'}

)

{ "ok" : 1 }

mongos> db.adminCommand(

{shardcollection:"pb2.hourly_stats"}

)

{ "ok" : 0, "errmsg" : "no shard key" }

mongos> db.adminCommand({shardcollection:"pb2.hourly_stats", key:{_id:1}})

{ "collectionsharded" : "pb2.hourly_stats", "ok" : 1 }

mongos> db.adminCommand({shardcollection:"pb2.aggregated_stats", key:{_id:1}})

{ "collectionsharded" : "pb2.aggregated_stats", "ok" : 1 }

mongos> show collections
aggregated_stats
hourly_stats
log_files
system.indexes
<At this point I run a script which inserts a bunch of objects into the log_files collection, implicitly creating it>
mongos> db.log_files.ensureIndex(

{status:1}

)
Sat Feb 4 06:07:08 uncaught exception: getlasterror failed: {
"assertion" : "nextSafe():

{ $err: \"unrecognized command: setShardVersion\", code: 13390 }

",
"assertionCode" : 13106,
"errmsg" : "db assertion failure",
"ok" : 0
}



 Comments   
Comment by Randolph Tan [ 25/May/12 ]

The setShardVersion command is triggered when the getLastError command was called. And since the ScopedDBConnection was used to the mongos host when processing addShard, the callback for onCreate gets triggered, which results in the mongos host being added to the getLastError host. This is already fixed in SERVER-5243.

As for the segfault, it was caused by an error in the test script, calling

{ shardCollection: 'test', ... }

instead of

{ shardCollection: 'test.user', ... }

. A separate ticket (SERVER-5926) has been created to handle this issue.

Comment by Randolph Tan [ 24/May/12 ]

Confirmed to be reproducible. The setShardVersion failure happens when trying to register a writebackListener on the other mongos shard (that was passed to the failed addShard command). Needs to investigate further. In 2.1.2, the mongod shard would get a segmentation fault every time even before the procedure is completed.

Comment by Eliot Horowitz (Inactive) [ 04/Feb/12 ]

The initial addShard with a mongos is probably being cached somewhere.

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