[SERVER-13690] Can't add tag ranges when sharding on subdocument fields Created: 23/Apr/14  Updated: 01/Jan/16  Resolved: 23/Apr/14

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

Type: Bug Priority: Major - P3
Reporter: Joanna Cheng Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-6999 Embedded "dot-notation" fields broken... Closed
Operating System: ALL
Participants:

 Description   

Enable sharding, shard a collection with a subdocument field, add tag range, tag a shard:

sh.enableSharding("test")
sh.shardCollection("test.foo", {"a.b": 1})
sh.addTagRange("test.foo", {a: {b: "AP"}}, {a: {b: "AQ"}}, "AP")
sh.addShardTag("shard0002", "AP") // or pick a shard that's NOT the primary shard

This gives an error in the logs

Wed Apr 23 12:03:52.252 [Balancer] Assertion: 16634:field names of bound { a: { b: "AP" } } do not match those of keyPattern { a.b: 1.0 }
0x1002a106b 0x10027d71e 0x10027d7dd 0x1000f256e 0x10016216e 0x10015fae6 0x10027edb5 0x10027f4ea 0x10027f5b6 0x10027f676 0x1002d39e5 0x7fff91189899 0x7fff9118972a 0x7fff9118dfc9

As this error suggests, this doesn't work:

db.foo.insert({a: {b: "AP"}, i:1})
sh.status() // shows chunk still on primary shard, not tagged shard

We can't make the shard tag match the shard key:

> sh.addTagRange("test.foo", {"a.b": "AP"}, {"a.b": "AQ"}, "AP")
Wed Apr 23 12:06:41.756 JavaScript execution failed: can't have . in field names [a.b] at src/mongo/shell/collection.js:L143

This is because sh.addTagRange() is basically doing this:

use config
db.tags.insert({ "_id" : { "ns" : "test.foo", "min" : { "a.b" : "AP" }  }, "ns" : "test.foo", "min" : { "a.b" : "AP" }, "max" : { "a.b" : "AQ"  }, "tag" : "AP" })

And although these are valid javascript and JSON field names, they are not valid for MongoDB (https://docs.mongodb.org/manual/reference/limits/#Restrictions-on-Field-Names)

We also can't change the shard key format:

> sh.shardCollection("test.bar", {a: {b:1}})
{
	"ok" : 0,
	"errmsg" : "Unsupported shard key pattern.  Pattern must either be a single hashed field, or a list of ascending fields."
}



 Comments   
Comment by Eliot Horowitz (Inactive) [ 23/Apr/14 ]

Dup of SERVER-6999

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