[SERVER-72993] Support running bulkWrite commands in internal transactions Created: 18/Jan/23  Updated: 10/Nov/23  Resolved: 10/Nov/23

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

Type: Task Priority: Major - P3
Reporter: Lingzhi Deng Assignee: Backlog - Replication Team
Resolution: Won't Fix Votes: 0
Labels: milestone-3
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Replication
Participants:

 Description   

What we built in PM-2210 was to allow (internal) transactions to opt into storing history for each stmtId and then return the original response if some stmtId is retried. This should work out of the box for bulkWrite as bulkWrite also accepts a vector of stmtIds as its input. If a bulkWrite is executed inside an internal transaction on behalf of a client retryable write request, each op in the bulkWrite should have the same stmtId as its corresponding original write statement. Such bulkWrite may contain additional write statements that are not explicitly requested by a client retryable write command. In that case, we should assign stmtId kUninitializedStmtId (-1) for those auxiliary ops when executing bulkWrite in the internal transaction. Like insert/update/delete, the bulkWrite command will also include an unstable retriedStmtIds field in its response used internally to support retryability when running bulkWrite inside an internal transaction.

This ticket should make sure the retriedStmtIds field is properly used and add tests for running bulkWrite in internal transactions (especially for retryability).



 Comments   
Comment by Lingzhi Deng [ 10/Nov/23 ]

Retryable timeseries update for bulkWrite already uses the bulkWrite internal txn api so we get test coverage via that.

Comment by Sean Zimmerman [ 02/May/23 ]

I agree that is probably the easiest way to test this

Comment by Lingzhi Deng [ 01/May/23 ]

Additional, I wonder if we would want to "upgrade" some of the internal transaction API usages (e.g. the ones in fle_crud.cpp) to use the bulkWrite transaction API SERVER-72991 built. I think having at least one internal usage of bulkWrite in internal transactions would also be a good way to test the API we built. CC sean.zimmerman@mongodb.com 

Comment by Lingzhi Deng [ 01/May/23 ]

I think SERVER-72988 and SERVER-72989 will probably make this work out of the box assuming we will attach stmtIds and return retriedStmtIds correctly. I think the bigger lift for this ticket is how we should test this. We have a lot of internal transaction retryability test under jstests/sharding/internal_txns, e.g. retryable_writes_retry_in_different_batches.js. Unless they are covered by our shell method override effort, we should probably add tests there for running bulkWrite in an internal transactions.

Generated at Thu Feb 08 06:23:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.