[SERVER-69901] Fix racy initialization of `CommandInvocationHooks` Created: 22/Sep/22  Updated: 29/Oct/23  Resolved: 11/Oct/22

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

Type: Bug Priority: Major - P3
Reporter: Amirsaman Memaripour Assignee: Celina Tala
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: Service Arch 2022-10-17
Participants:
Linked BF Score: 5

 Description   

CommandInvocationHooks are defined as a decoration on ServiceContext and define server-specific behavior that should run before and after running commands.

Accesses to this decoration are not synchronized, so initializing it after its first use may case data races. For example, mongod initializes these hooks from here, however, other threads may access the hooks as part of running commands before it is initialized (e.g., ReadThroughCache.

This ticket should address this data race, either by proposing an alternative initialization order or adopting synchronization primitives.



 Comments   
Comment by Githook User [ 10/Oct/22 ]

Author:

{'name': 'Celina Tala', 'email': 'celinahtala@gmail.com', 'username': 'celinatala-1'}

Message: SERVER-69901 Moved `initializeCommandHooks` to before `ServiceEntryPoint` is set
Branch: master
https://github.com/mongodb/mongo/commit/1ea5545dac92683baafbab6c53d721d80b376ece

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