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:
- 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.
- Get fixedExecutor and for both the delete and insert commands and schedule the following work:
- Create a new opCtx
- Create OpMsgRequest
- 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.