[SERVER-39926] Migrations may not transfer writes from prepared transactions committed during cloning phase Created: 01/Mar/19  Updated: 29/Oct/23  Resolved: 08/Mar/19

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

Type: Bug Priority: Major - P3
Reporter: Jack Mulrow Assignee: Blake Oler
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Sharding 2019-03-11
Participants:
Linked BF Score: 7

 Description   

If a transaction commits during the cloning phase of a chunk migration on the donor shard, any writes from the transaction are added to the transfer mods buffer by an op observer that registers onCommit handlers on the WriteUnitOfWork of the opCtx given to the observer.

This relies on the WUOW committing and its handlers running before the locks associated with the transaction are dropped, so the donor shard can't enter the critical section without seeing the writes (which requires an X lock on the migrating collection).

This is true for transactions that commit without prepare, but when committing a prepared transaction, the transaction is committed to storage and its locks are dropped before the transaction commit op observer runs with a new WUOW. This allows the donor shard to enter the critical section and finish the migration without transferring the transaction's writes to the recipient, losing data.



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

Author:

{'name': 'Blake Oler', 'username': 'BlakeIsBlake', 'email': 'blake.oler@mongodb.com'}

Message: SERVER-39926 Observe prepared transactions on prepare for migration to guarantee collection locking
Branch: master
https://github.com/mongodb/mongo/commit/52f41f0a7aeaac855ce088387d1d82148bfba6e0

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