-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 6.1.0-rc0
-
Component/s: None
-
Labels:None
-
Fully Compatible
-
ALL
-
Server Serverless 2022-08-08
-
145
Remove the lock from ShardSplitDonorService::DonorStateMachine::checkIfOptionsConflict. Create const member fields like tenant_migration_donor_service (https://github.com/10gen/mongo/blob/103cf67c1488288beb7d8bd68f3550a612d6d054/src/mongo/db/repl/tenant_migration_donor_service.h#L288-L296) so lock is not needed to check options.
Change is aimed to avoid deadlock when:
(1) Instance lock is held in ShardSplitDonorService::DonorStateMachine::run (https://github.com/10gen/mongo/blob/9743d69c7dbc92fd5abcf9c799daff89e30ca233/src/mongo/db/serverless/shard_split_donor_service.cpp#L335)
(2) POS lock is held ShardSplitDonorService::getOrCreateInstance (https://github.com/10gen/mongo/blob/9743d69c7dbc92fd5abcf9c799daff89e30ca233/src/mongo/db/repl/primary_only_service.cpp#L543)
(3) getOrCreateInstance -> ShardSplitDonorService::DonorStateMachine::checkIfOptionsConflict waits on instance lock (https://github.com/10gen/mongo/blob/9743d69c7dbc92fd5abcf9c799daff89e30ca233/src/mongo/db/serverless/shard_split_donor_service.cpp#L295)
(2) onCreateOperationContext -> ShardSplitDonorService::registerOpCtx waits on POS lock (https://github.com/10gen/mongo/blob/9743d69c7dbc92fd5abcf9c799daff89e30ca233/src/mongo/db/repl/primary_only_service.cpp#L261).