[SERVER-45945] Prohibit collection/index creation inside prepared transactions Created: 04/Feb/20  Updated: 14/Feb/20  Resolved: 14/Feb/20

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

Type: Task Priority: Major - P3
Reporter: Maria van Keulen Assignee: Maria van Keulen
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Duplicate
duplicates SERVER-45405 Allow implicit collection creation in... Closed
Related
related to SERVER-46105 Allow new collection creation inside ... Backlog
related to SERVER-45368 Allow collection and index creation i... Closed
Sprint: Execution Team 2020-02-10, Execution Team 2020-02-24
Participants:

 Description   

This ticket is split from SERVER-45368, which allows collection and index creation inside unprepared transactions in a sharded cluster.

The work to make collection and index creation function inside prepared transactions is nontrivial, and there are crash scenarios that can happen presently (see my comment). This ticket will fix those crash scenarios by disallowing collection and index creation (and any other commands) from prepared transactions.



 Comments   
Comment by Maria van Keulen [ 14/Feb/20 ]

I'll be fixing this as part of SERVER-45405, since the present issues with prepare get exposed in the testing for SERVER-45405.

Comment by Maria van Keulen [ 07/Feb/20 ]

It looks like there is a wrinkle for prepared transactions. In order to set a prepare timestamp for the transaction on the secondary, we need to have applied all of the operations inside of the transactions. In order to apply a command, we need to call applyCommand_inlock during _applyOperationsForTransaction. During applyCommand_inlock, we assign a command timestamp to the command in most cases. We then create a TimestampBlock, which in turn calls setCommitTimestamp, which invariants that we are either outside a WUOW (not true, since we've unstashed our transaction resources) or we have set a prepare timestamp (not true, since we need to have applied all of our operations to set it).
I will update the title and description of the ticket to ensure that collection and index creation cannot occur inside prepared transactions, given this wrinkle.

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