[SERVER-11000] Insert issue. Created: 02/Oct/13  Updated: 02/Oct/13  Resolved: 02/Oct/13

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

Type: Bug Priority: Major - P3
Reporter: Chris Beck Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

mongos> db.FeedData.insert(

{ item: "card", qty: 15 }

)
error preparing documents for insert :: caused by :: tried to insert object with no valid shard key for

{ d.auction_id_64: "hashed" }

:

{ _id: ObjectId('524c0a6b3a6b2a9f5ee3621d'), item: "card", qty: 15.0 }

mongos> db.FeedData.insert(

{ item: "card", qty: 15, 'd.auction_id_64': 1234 }

)
Wed Oct 2 11:59:03.877 can't have . in field names [d.auction_id_64] at src/mongo/shell/collection.js:143
mongos>

The only problem here is shard key is d.auction_id_64. What am I missing here?!

{ "_id" : "lld", "partitioned" : true, "primary" : "mongo-cl1-sh1" }

lld.FeedData
shard key:

{ "d.auction_id_64" : "hashed" }

chunks:
mongo-cl1-sh1 2
mongo-cl1-sh10 2
mongo-cl1-sh2 2
mongo-cl1-sh3 2
mongo-cl1-sh4 2
mongo-cl1-sh5 2
mongo-cl1-sh6 2
mongo-cl1-sh7 2
mongo-cl1-sh8 2
mongo-cl1-sh9 2



 Comments   
Comment by Scott Hernandez (Inactive) [ 02/Oct/13 ]

You cannot have "." in field names . The index and shard key are specified using dot-notation but your documents don't have field names with dots in them.

What you are want is an embedded field/document like this:

> docWithShardKey = { _id:234, item: "card", qty:15, d: { auction_id_64: 1234} }
> db.FeedData.insert(docWithShardKey)

Comment by Chris Beck [ 02/Oct/13 ]

Fairly certain this is a bug... This worked as expected:

mongos> sh.shardCollection('lld.FeedData',

{'auction_id_64':'hashed'}

);

{ "collectionsharded" : "lld.FeedData", "ok" : 1 }

mongos> db.FeedData.insert(

{ item: "card", qty: 15 }

)
error preparing documents for insert :: caused by :: tried to insert object with no valid shard key for

{ auction_id_64: "hashed" }

:

{ _id: ObjectId('524c0bf13a6b2a9f5ee3621f'), item: "card", qty: 15.0 }

mongos> db.FeedData.insert(

{ item: "card", qty: 15, auction_id_64:22333 }

)
mongos>

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