[SERVER-84730] It's unsafe to reuse OpCtx for multiple operations when queryStats is concurrently disabled Created: 10/Jan/24  Updated: 22/Jan/24  Resolved: 22/Jan/24

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

Type: Bug Priority: Major - P3
Reporter: Charlie Swanson Assignee: Charlie Swanson
Resolution: Fixed Votes: 0
Labels: qi-query-stats
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
related to SERVER-85405 Factor out code to set up and tear do... Backlog
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:
Linked BF Score: 30

 Description   

The fuzzer found this problem via the FTDC background thread which appears to run a couple back-to-back aggregation commands using the same OperationContext. What seems to be happening is the following:

  1. FTDC thread begins, and issues one aggregation which successfully records query stats.
  2. Another thread disables query stats by setting the cache size to 0.
  3. (back in FTDC) With the same OperationContext, but a different collector, we run a second aggregate.
  4. This second aggregate shares the old OperationContext (and CurOp, and OpDebug) which still has a query stats key hash on it, but will never have a query stats key, because query stats has been disabled.

This doesn't cause too much trouble, it just causes us to miss that one recording for FTDC. The thread can continue without crashing or anything.



 Comments   
Comment by Githook User [ 22/Jan/24 ]

Author:

{'name': 'Charlie Swanson', 'email': 'charlie.swanson@mongodb.com', 'username': 'cswanson310'}

Message: SERVER-84730 Update query stats assertions (#18043)

GitOrigin-RevId: 0766fb001ac394aec4410d27276d1721fb72ff8a
Branch: master
https://github.com/mongodb/mongo/commit/04c36b7c059bb2807f2a2dde9ff63d87e44285eb

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