[SERVER-69918] Produce upsert document in _clusterQueryWithoutShardKey Created: 22/Sep/22  Updated: 29/Oct/23  Resolved: 24/Feb/23

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

Type: Task Priority: Major - P3
Reporter: Jason Zhang Assignee: Sanika Phanse (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-72198 Separate query_exec executable in scons Closed
related to SERVER-72806 Split produceNewDocumentForInsert int... Closed
related to SERVER-73417 Change method signature for produceUp... Closed
Backwards Compatibility: Fully Compatible
Sprint: Sharding 2022-10-17, Sharding 2022-12-12, Sharding NYC 2022-12-26, Sharding NYC 2023-01-09, Sharding NYC 2023-01-23, Sharding NYC 2023-02-06, Sharding NYC 2023-02-20, Sharding NYC 2023-03-06
Participants:

 Description   

On upsert:true and no matches found for a document, return the necessary upsert document to insert on a shard.



 Comments   
Comment by Githook User [ 25/Feb/23 ]

Author:

{'name': 'Sanika Phanse', 'email': 'sanika.phanse@mongodb.com', 'username': 'sphanse99'}

Message: SERVER-69918 Produce upsert document in _clusterQueryWithoutShardKey
Branch: master
https://github.com/mongodb/mongo/commit/8a53ac6194cbd298e517fc4102263facf9f66ede

Comment by Sanika Phanse (Inactive) [ 09/Jan/23 ]

While waiting for SERVER-72198, I tried using the `query_exec` binary directly in `cluster_commands` library as a quick fix, but this failed with errors related to cursor server status metrics conflicts caused by these files.

Paired with arun.banala@mongodb.com today to separate the cursor files into a separate binary, but found that the difficulty to do this is comparable with that of SERVER-72198. Since SERVER-72198 is the more correct solution, we have decided to increase the priority for SERVER-72198 instead and will circle back to SERVER-69918 when it's done. If SERVER-72198 ultimately proves unfeasible, we will revisit moving the mongod cursor stats files into a separate binary.

I'm reopening this ticket, pending SERVER-72198.

Comment by Sanika Phanse (Inactive) [ 30/Nov/22 ]

Bringing upsert_stage.cpp into mongos's scope in order to use a modified version of produceNewDocumentForInsert() when no matching documents &

{upsert:true}

is detected here. To do this, make a series of functions static:

(1) UpsertStage::produceNewDocumentForInsert()
(2) UpdateDriver::populateDocumentWithQueryFields (called in (1))

Currently, (1) functions as follows:

  • (1) Creates a list of "immutable paths", namely _id & shard key in some cases (shard key restrictions will not apply for this project)
  • (2) Creates a "pre-image" document using the request query.
  • (3) Generate post-image following a strategy for replacement style updates and a strategy for all other updates
  • (4) Validates and returns.

The logic in (1) can be simplified as we can make a few assumptions:

  • The collection is sharded
  • No locks should be acquired
  • Only _id is immutable
Generated at Thu Feb 08 06:14:47 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.