Problem/Motivation
Each message template in the watchdog collection has one capped event collection, watchdog_event_<template id>. The template collection is the registry of event collections, but nothing checks that the two agree, and they can drift, e.g. as a consequence of #3628821: Race condition in Logger::log() :
- an event collection without a template, which no page can reach;
- a template without an event collection, whose events page is empty;
- an event collection that is not capped, which grows without limit: the race in
Logger::log()on a template's first event can create one.
drush mongodb:watchdog:sanitycheck reports none of these: it only buckets event collections by document count. SanityCheck::buildCollectionstats() also counts the documents of every collection in the logger database before testing whether its name is an event collection, so it counts the template and tracker collections for nothing.
Steps to reproduce
n.a.
Proposed resolution
- Report the three cases above, by comparing the template ids with one unfiltered listing of the collections and their options.
- Add a rebuild option that repairs what can be repaired: create a missing event collection capped, and cap an uncapped one to the configured size.
- In
buildCollectionstats(), test the collection name before counting its documents.
Remaining tasks
- Decide whether this is a new Drush command or an extension of
mongodb:watchdog:sanitycheck. - Decide what the rebuild does with an event collection that has no template: report only, or drop it. Its events cannot be displayed without the template's message.
- Implementation and tests.
User interface changes
None in the web UI; a new Drush command or new options on an existing one.
API changes
None expected.
Data model changes
None.
AI disclosure
This issue was prepared with AI assistance. MRs may use it too: update this section accordingly.
Comments