[DOCS-12742] Docs for SERVER-39158: Change updates to prefer target by the query Created: 22/May/19  Updated: 13/Nov/23  Resolved: 22/Aug/19

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: 4.1.12, Server_Docs_20231030, Server_Docs_20231106, Server_Docs_20231105, Server_Docs_20231113

Type: Task Priority: Major - P3
Reporter: Kay Kim (Inactive) Assignee: Kay Kim (Inactive)
Resolution: Fixed Votes: 0
Labels: docs-4.2-sharding
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
documents SERVER-39158 Change updates to prefer target by th... Closed
Participants:
Days since reply: 4 years, 24 weeks, 6 days ago
Epic Link: DOCS: 4.2 Server/Tools

 Description   

Description

Description:

The ticket changes the routing behaviour for updates on sharded clusters.

1. Replacement-style updates will now attempt to target by the query first.

2. If we cannot target a single shard, and if the op is NOT an upsert, we fall back to targeting by the replacement document in order to maintain backwards-compatible behaviour.

3. If the op is an upsert, then we do NOT fall back to targeting by replacement; an upsert must always target a single shard by query and must have full shard key in query. If we cannot do so, we throw an operation-fatal exception.

4. This change also enforces the requirement of needing a full shard key in the query to update a shard key value.

Engineering Ticket Description:

Currently, replacement style updates target using the update rather than the query. We should change this to target using the query instead.

As of today, we do not allow users to change the shard key for a document. If shard 1 owns the chunk with range (shardKey : min, shardKey : 500) and shard 2 owns the chunk with range (shardKey : 500, shardKey : max) and a user sends

db.coll.update({shardKey : 100}, {shardKey : 800})

the update will be sent to shard 2 and we return

{ok: 1.0, nMatched : 0)

We should actually get an ImmutableField error.

Once we allow a user to update the shard key for a document (PM-1163), the above update should cause the document to change shards. However, since the update would be sent to shard 2, shard 1 will never actually see this update and the update will not be applied.

Scope of changes

Impact to Other Docs

MVP (Work and Date)

Resources (Scope or Design Docs, Invision, etc.)



 Comments   
Comment by Githook User [ 22/Aug/19 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@10gen.com', 'username': 'kay-kim'}

Message: DOCS-12742: 4.2 sharded collection updates
Branch: master
https://github.com/mongodb/docs/commit/1a9eef4200e4860b7e3ba765401b6ea2a7794309

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