[SERVER-46196] Failed collection creation leaves an orphaned entry inside Top data structure Created: 14/Feb/20  Updated: 29/Oct/23  Resolved: 25/Feb/20

Status: Closed
Project: Core Server
Component/s: Catalog
Affects Version/s: None
Fix Version/s: 4.3.4

Type: Bug Priority: Major - P3
Reporter: David Storch Assignee: David Storch
Resolution: Fixed Votes: 0
Labels: greenerbuild, qexec-team
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
is related to SERVER-45137 Increasing memory allocation in Top::... Closed
is related to SERVER-6627 top command should return cursor Backlog
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Query 2020-02-24, Query 2020-03-09
Participants:
Linked BF Score: 26

 Description   

Instances of various types of operations, along with information about their durations, are tracked for diagnostic purposes in-memory inside the Top data structure. Users can then access this information via the top command or the $collStats agg stage with the "latencyStats" option.

The code path for creating a new collection records information into Top using the AutoStatsTracker. The AutoStatsTracker's destructor will write an entry into Top by calling Top::record(). The problem is that this destructor will run and add info to Top whether or not the collection creation succeeds. If the collection creation fails, then there will be an entry for a non-existent collection in Top. Worse, attempting to drop this non-existent collection will not clear the extra entry. This could essentially manifest as a memory leak, causing Top's memory footprint to grow over time. This situation can be corrected by restarting the server.

Another possible symptom is that an attempt to run the "top" command could fail with a BSONObjectTooLarge error (or similarly fail when trying to grow a BufBuilder). Until SERVER-6627 is implemented in order to report top data via a cursor, the command will fail when the top diagnostic data exceeds 16MB. Also, data about non-existent collections will erroneously appear in the top command output.

Finally, note that we similar diagnosed and fixed a similar issue in related ticket SERVER-45137.



 Comments   
Comment by Githook User [ 25/Feb/20 ]

Author:

{'name': 'David Storch', 'username': 'dstorch', 'email': 'david.storch@mongodb.com'}

Message: SERVER-46196 Fix creation of orphan Top entries on failed collection creation
Branch: master
https://github.com/mongodb/mongo/commit/bc4caba144ed5a422609a8400e1ba8cb5a88810a

Generated at Thu Feb 08 05:10:47 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.