[SERVER-39835] Create interface to run delete and insert in transaction Created: 26/Feb/19  Updated: 29/Oct/23  Resolved: 07/Mar/19

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

Type: Task Priority: Major - P3
Reporter: Janna Golden Assignee: Janna Golden
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Sharding 2019-03-11
Participants:

 Description   

In order to update a document's shard key value, we need to delete the old document and insert the new document. This should be done in an already running transaction.

Implementation details:

  1. Build delete and insert command objects. Use the original query from the update as the query for the delete and the post-image created by the update stage as the documents field for the insert (attached to WouldChangeOwningShard exception). Use the lsid, txnNumber, and stmtId from the original write.
  2. Get fixedExecutor and for both the delete and insert commands and schedule the following work:
    1. Create a new opCtx
    2. Create OpMsgRequest
    3. Pass the OpMsgRequest to serviceEntryPoint->handleRequest()

This should be able to be used in both batch_write_exec.cpp and cluster_find_and_modify.cpp. We should also create unit tests for this logic as a part of this ticket.



 Comments   
Comment by Githook User [ 07/Mar/19 ]

Author:

{'name': 'jannaerin', 'username': 'jannaerin', 'email': 'golden.janna@gmail.com'}

Message: SERVER-39835 Create interface to update document shard key within already running txn

Co-authored-by: BlakeIsBlake blake.oler@mongodb.com
Branch: master
https://github.com/mongodb/mongo/commit/c6f1019c261b5bde912e720605ce7f74f3113270

Comment by Blake Oler [ 28/Feb/19 ]

As part of this, we will need to add the post-image _id to the query predicate when we are doing the delete.

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