[SERVER-26750] Don't log a Top entry in ~AutoGetCollectionForRead() if database is dropped Created: 24/Oct/16  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Diagnostics
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Kyle Suarez Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: open_todo_in_code
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-26425 Top entries may remain if write confl... Closed
Assigned Teams:
Query Execution
Participants:
Linked BF Score: 0

 Description   

We expect that Top does not contain entries for collections which no longer exist. When a database is dropped, we clear all of the collections in that database from Top. However, consider the following scenario:

  1. We drop some database; say test. dropDatabase acquires a database lock in mode X.
  2. dropDatabase takes a while, and the cursor timeout thread runs on a collection in test.
  3. The cursor timeout thread uses AutoGetCollectionForRead and acquires a database lock in mode IS.
  4. The cursor timeout thread blocks until dropDatabase succeeds. After completing its work, the destructor of AutoGetCollectionForRead logs an entry in Top, even though the namespace no longer exists.

We should fix the destructor of AutoGetCollectionForRead so that this logging does not occur if the database has been dropped. Note that the trivial fix of only calling Top::record() if _autoColl->getDb() != nullptr is not sufficient because this breaks Top recording for views. (Specifically, AutoGetCollectionOrViewForRead destroys its _autoColl when releasing its locks after resolving a view.)


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