[SERVER-28739] make the js scripting engine correctly verify that accessed collections are unsharded Created: 11/Apr/17 Updated: 12/Oct/17 Resolved: 14/Apr/17 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Sharding |
| Affects Version/s: | 3.5.5 |
| Fix Version/s: | 3.5.6 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Esha Maharishi (Inactive) | Assignee: | Esha Maharishi (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Operating System: | ALL |
| Sprint: | Sharding 2017-04-17, Sharding 2017-05-08 |
| Participants: |
| Description |
|
The eval command on mongod calls into the js scripting engine. Since eval() is called on a database, not a namespace, it does not check the shardVersion sent in the request (or the shardVersion for the connection) directly. Instead, any time a namespace is accessed by the script, the scripting engine checks that the namespace is not sharded (in DBInfo::getProperty() and DBCollectionInfo::construct). It does this check by calling ShardingState::haveLocalShardingInfo():
This function assumes the collection is sharded if: 1) the OperationShardingState has a shardVersion (aka, a shardVersion was attached to the command in the request) The mongos EvalCmd, which forwards the command to the primary shard for the database eval() was run on, does not attach a shardVersion to the cmdObj. On the other hand, the passthrough() function called by mongos's EvalCmd uses ShardConnection on an empty namespace. Therefore, only if the connection mongos gets from the pool had previously set a shardVersion for a namespace accessed by the script (e.g., due to a different, prior command), will the shard host have a ShardedConnectionInfo with a non-UNSHARDED version for the namespace, and only in this case will the haveLocalShardingInfo() check on mongod work if the collection is sharded. |
| Comments |
| Comment by Githook User [ 17/Apr/17 ] |
|
Author: {u'username': u'EshaMaharishi', u'name': u'Esha Maharishi', u'email': u'esha.maharishi@mongodb.com'}Message: |
| Comment by Githook User [ 17/Apr/17 ] |
|
Author: {u'username': u'EshaMaharishi', u'name': u'Esha Maharishi', u'email': u'esha.maharishi@mongodb.com'}Message: Revert " This reverts commit d44e25dde3c61d729b8e97a2118e15ec80683c83. |
| Comment by Githook User [ 17/Apr/17 ] |
|
Author: {u'username': u'EshaMaharishi', u'name': u'Esha Maharishi', u'email': u'esha.maharishi@mongodb.com'}Message: |
| Comment by Githook User [ 14/Apr/17 ] |
|
Author: {u'username': u'EshaMaharishi', u'name': u'Esha Maharishi', u'email': u'esha.maharishi@mongodb.com'}Message: |