[SERVER-27735] Remove uses of config.chunks' _id field Created: 18/Jan/17  Updated: 06/Dec/22  Resolved: 02/Jan/18

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

Type: Improvement Priority: Major - P3
Reporter: Dianna Hohensee (Inactive) Assignee: [DO NOT USE] Backlog - Sharding Team
Resolution: Won't Fix Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-8829 String representation for chunk id is... Closed
Assigned Teams:
Sharding
Sprint: Sharding 2017-03-27
Participants:

 Description   

The value of _id is a string concatenation of namespace and minkey values. Reads/updates can instead by done directly on the ns and min, for which there is an index.

We wish to eventually change the schema of the config.chunks collection, because it is not optimized. The first step is to stop using (reading) the _id field so that it can more easily (less backwards compatibility issues) be changed in future releases. It is currently used to identify documents in updates, which can be found by grepping for instances of ChunkType::name.

For future reference, a first sketch of a more ideal schema is:

{_id: {ns : " ", min: keystring}, shard: "string", ....}

Schema changes should be revisited after the collection UUID project (PM-297) is designed because that project could require config.chunks schema changes.



 Comments   
Comment by Kaloian Manassiev [ 20/Dec/17 ]

This ticket will become obviated as part of the config.chunks schema redesign happening under the 'Multi-versioned Routing Table' project.

Putting it under this Epic, but there shouldn't be any work to be done specifically for this ticket.

Comment by Kaitlin Mahar [ 08/Dec/17 ]

In attempting to make this change, ran into the issue that applyOps requires the query document in an update operation to contain an _id field (in code here).

In particular, I changed the query document o2 from

BSONObjBuilder q(op.subobjStart("o2"));
q.append(ChunkType::name(), ChunkType::genID(nss.ns(), startKey));
q.done();

to

BSONObjBuilder q(op.subobjStart("o2"));
q.append(ChunkType::ns(), nss.ns());
q.append(ChunkType::min(), startKey);

And this causes jstests/sharding/addshard1.js to fail when attempting to split a collection into chunks (here). See log from that test failing here.

So we will be unable to make these unless if applyOps changes.

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