[SERVER-24174] Inconsistent rule for storing dotted field names Created: 16/May/16  Updated: 05/Mar/18  Resolved: 12/Oct/17

Status: Closed
Project: Core Server
Component/s: Sharding, Storage
Affects Version/s: 3.3.6
Fix Version/s: 3.6.0-rc1

Type: Bug Priority: Major - P3
Reporter: Randolph Tan Assignee: Nicholas Zolnierz
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-6999 Embedded "dot-notation" fields broken... Closed
Related
related to SERVER-29334 Cannot write shard chunks documents w... Closed
related to SERVER-29594 "update" can produce documents with d... Closed
related to DOCS-10896 Updating naming restrictions on field... Closed
is related to SERVER-10454 Do not store field names with "." in ... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Query 2017-10-23
Participants:

 Description   

It looks like _id field has stricter rules than other fields:

> db.getMongo()._skipValidation = true
true
> db.user.insert({ x: { 'a.b': 1 }})
WriteResult({ "nInserted" : 1 })
> db.user.find()
{ "_id" : ObjectId("573a41831b3dd58ca2e7f085"), "x" : { "a.b" : 1 } }
> db.user.insert({ _id: { 'a.b': 1 }})
WriteResult({
	"nInserted" : 0,
	"writeError" : {
		"code" : 57,
		"errmsg" : "a.b is not valid for storage."
	}
})

In more detail, the dotted field names is currently disallowed in:

  • top level fields
  • any level inside _id

and is allowed any other place

Also note that mongos is already relying on this behavior:

mongos> db.adminCommand({ enableSharding: 'test' })
{ "ok" : 1 }
mongos> db.adminCommand({ shardCollection: 'test.user', key: { 'x.y': 1 }})
{ "collectionsharded" : "test.user", "ok" : 1 }
mongos> use config
switched to db config
mongos> db.chunks.find()
{ "_id" : "test.user-x.y_MinKey", "ns" : "test.user", "min" : { "x.y" : { "$minKey" : 1 } }, "max" : { "x.y" : { "$maxKey" : 1 } }, "shard" : "shard0000", "lastmod" : Timestamp(1, 0), "lastmodEpoch" : ObjectId("573a41e5741a236015ac3ec9") }
mongos> db.collections.find()
{ "_id" : "test.user", "lastmodEpoch" : ObjectId("573a41e5741a236015ac3ec9"), "lastmod" : ISODate("1970-02-19T17:02:47.296Z"), "dropped" : false, "key" : { "x.y" : 1 }, "unique" : false }



 Comments   
Comment by Githook User [ 12/Oct/17 ]

Author:

{'email': 'nicholas.zolnierz@mongodb.com', 'name': 'Nick Zolnierz', 'username': 'nzolnierzmdb'}

Message: SERVER-24174: Inconsistent rule for storing dotted field names
Branch: master
https://github.com/mongodb/mongo/commit/b5cea947a24609d098d4e5d691a1b7a9a8debb1d

Comment by Randolph Tan [ 17/May/16 ]

scotthernandez Added:

In more detail, the dotted field names is currently disallowed in:
top level fields
any level inside _id
and is allowed any other place

to the description. This ticket is mainly about deciding whether to completely disallow dotted field names every where or no where. Or if we decide to keep the current behavior, make sure that it is documented.

Comment by Scott Hernandez (Inactive) [ 17/May/16 ]

What behavior/actions do you expect to come out of this server issue?

Or better yet, can you describe the bug and what a "fix" is?

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