[SERVER-68528] Remove use of shared_mutex from SchedulingTicketHolder Created: 03/Aug/22  Updated: 29/Oct/23  Resolved: 08/Sep/22

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

Type: Task Priority: Major - P3
Reporter: Andy Schwerin Assignee: Jordi Olivares Provencio
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
Backwards Compatibility: Fully Compatible
Sprint: Execution Team 2022-09-05, Execution Team 2022-09-19
Participants:
Linked BF Score: 120

 Description   

The `SchedulingTicketHolder` type uses `std::shared_mutex`, which is not generally allowed in production mongodb code. If a reader-writer mutex is required, the LockManager's ResourceMutex type is the currently recommended type.



 Comments   
Comment by Andy Schwerin [ 14/Sep/22 ]

Thanks jordi.olivares-provencio@mongodb.comand geert.bosch@mongodb.comfor publishing the benchmark and the reasoning for why shared_mutex is appropriate here. I learned things!

Comment by Githook User [ 08/Sep/22 ]

Author:

{'name': 'Jordi Olivares Provencio', 'email': 'jordi.olivares-provencio@mongodb.com', 'username': 'jordiolivares'}

Message: SERVER-68528 Explain shared_mutex in SchedulingTicketHolder
Branch: master
https://github.com/mongodb/mongo/commit/7da8cf1b0e10cec512ae6a3fc711c880fb77c261

Comment by Geert Bosch [ 07/Sep/22 ]

We talked and agree that both ResourceMutex is not appropriate here, and that usual reasons for avoiding std::shared_mutex do not apply:

  • no reader or writer starvation is possible, regardless of the policy of the {{shared_mutex }}implementation
  • neither read nor write operations can take long (no potentially blocking calls while holding the mutex, no need for statistics or interruption)

So, it is ok for the TicketHolder to use the shared_mutex here with an appropriate comment.

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