[SERVER-35576] Fix PlanCacheClear::clear time of check/time of use bug Created: 13/Jun/18  Updated: 29/Oct/23  Resolved: 10/Sep/18

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: 4.1.3

Type: Bug Priority: Major - P3
Reporter: Ian Boros Assignee: Yuta Arai
Resolution: Fixed Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Query 2018-09-10, Query 2018-09-24
Participants:

 Description   

PlanCacheClear::clear, two checks happen: one for whether the cache entry exists, and another for whether removing it was successful:

https://github.com/mongodb/mongo/blob/56a4d894cc679db1ccd2336c490a1c3cd838f0d6/src/mongo/db/commands/plan_cache_commands.cpp#L313-L325

This strange because the call to contains() and remove() each acquire the plan cache mutex separately, so it's possible for something to happen between the two calls and for the command to return an error without logging a message. While this won't crash the server or do anything really nasty, we should fix it. This would just involve removing the call to contains().

I do not believe we'd need to add any specific testing for this.



 Comments   
Comment by Githook User [ 07/Sep/18 ]

Author:

{'name': 'yarai', 'email': 'yuta.arai@10gen.com', 'username': 'yarai'}

Message: SERVER-35576 Fixed PlanCacheClear clear time of check
Branch: master
https://github.com/mongodb/mongo/commit/5310a3a7ab70f44bd864c4738aa95d0165256945

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