[SERVER-52849] PrimaryOnlyService _rebuildServices accesses _scopedExecutor without locking the mutex Created: 13/Nov/20  Updated: 29/Oct/23  Resolved: 28/May/21

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 5.0.0-rc1

Type: Bug Priority: Major - P3
Reporter: Matthew Saltz (Inactive) Assignee: Tyler Seip (Inactive)
Resolution: Fixed Votes: 0
Labels: post-rc0, servicearch-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Duplicate
is duplicated by SERVER-56673 Race on _scopedExecutor between Prima... Closed
Related
is related to SERVER-53466 Race between PrimaryOnlyService::step... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v5.0
Sprint: Service Arch 2021-04-19, Service Arch 2021-05-17, Service Arch 2021-05-31
Participants:
Linked BF Score: 144
Story Points: 7

 Description   

This call to _rebuildInstances accesses _scopedExecutor without holding the mutex. This is a problem because on shutdown we swap _scopedExecutor with an empty executor. So if there is a step up, and then this lambda starts running but hangs before this line, and then a shutdown happens, _rebuildInstances could be using an empty/invalid _scopedExecutor. The same could possibly happen on step up - step down - step up, but it's a bit harder to follow.

I don't know if it's sufficient to just take the mutex in that callback since that might break other assumptions, so we might have to do some rearranging of things.

Acceptance criteria:

Ensure proper synchronization between onStepUp, onStepDown and shutdown. 



 Comments   
Comment by Githook User [ 28/May/21 ]

Author:

{'name': 'Tyler Seip', 'email': 'Tyler.Seip@mongodb.com', 'username': 'tseip-mongo'}

Message: SERVER-52849: Protect stepUp from invalidated executor on shutdown in PrimaryOnlyService
Branch: v5.0
https://github.com/mongodb/mongo/commit/83b21f4e299adf0c3158c14eb5f6c3ae4385c0b1

Comment by Githook User [ 28/May/21 ]

Author:

{'name': 'Tyler Seip', 'email': 'Tyler.Seip@mongodb.com', 'username': 'tseip-mongo'}

Message: SERVER-52849: Protect stepUp from invalidated executor on shutdown in PrimaryOnlyService
Branch: master
https://github.com/mongodb/mongo/commit/9eaa50dca26a9181108ba78b14d99e726af4755d

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