Problem/Motivation

Logger::eventCollections() lists the event collections with a regex on their name. MongoDB evaluates a name regex by scanning the whole collection catalog, so its cost grows linearly with the number of collections in the logger database, which holds one collection per message template.

Measured on MongoDB 8.3.11 while working on #3626728: Remove deprecated collStats after MongoDB release 6.2: the regex listing takes 1.7 to 2.6 s at 305,000 collections, where the exact-name listing that Logger::ensureCollection() runs stays under 1 ms p50 at every size from 1 to 305,000.

The module never needs this listing at runtime: the template collection (watchdog) already is the registry of event collections, and Logger::eventCollection() derives a collection from a template id. The only caller is ControllerTest::testLoggerAddAndUiClear(), which checks that clearing the logger dropped the event collections.

Steps to reproduce

n.a.

Proposed resolution

  • 8.x-2.2: deprecate the method, with @deprecated in mongodb:8.x-2.2 and is removed from mongodb:8.x-2.3. There is no replacement. and a @see to a change record, plus an E_USER_DEPRECATED notice in the method body. The change record explains the cost of the regex listing, and that the template collection is the way to find event collections.
  • 8.x-2.3: remove the method from Logger, and move the listing into the test that uses it.

Remaining tasks

  • Write the change record.
  • MR for 8.x-2.2: deprecation and notice.
  • MR for 8.x-2.3: removal, test helper.

User interface changes

None.

API changes

Logger::eventCollections() is deprecated in 8.x-2.2 and removed in 8.x-2.3.

Data model changes

None.

AI disclosure

This issue was prepared with AI assistance. MRs may use it too: update this section accordingly.

Comments

fgm created an issue. See original summary.

fgm’s picture

Priority: Normal » Minor

Lowering the priority to Minor, following the measurements posted on #3626728: Remove deprecated collStats after MongoDB release 6.2.

  • On MongoDB 4.0, the regex listing this method runs stalls collection creation and writes under load. From 4.2 on, it no longer does, so it cannot slow the rest of a site on any server version the module supports.
  • What remains is its own cost, which grows linearly with the collection count: about 60 ms at 10,000 collections and 0.5 s at 100,000 on MongoDB 8.3.

The method still has no runtime caller, and the template collection remains the way to find event collections, so withdrawing it is still worth doing, just not urgent.