fix: add TTL index to statistics collection for automatic cleanup#38568
fix: add TTL index to statistics collection for automatic cleanup#38568kodiakhq[bot] merged 4 commits intodevelopfrom
Conversation
|
Looks like this PR is ready to merge! 🎉 |
🦋 Changeset detectedLatest commit: fe92468 The changes in this PR will be included in the next version bump. This PR includes changesets to release 40 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughAdds a TTL index to the MongoDB statistics collection so documents expire after 365 days and updates the changelog to document the new automatic cleanup behavior. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #38568 +/- ##
===========================================
+ Coverage 70.45% 70.47% +0.01%
===========================================
Files 3176 3176
Lines 111476 111476
Branches 20130 20156 +26
===========================================
+ Hits 78545 78559 +14
+ Misses 30879 30872 -7
+ Partials 2052 2045 -7
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
6df9fef to
073dfa8
Compare
073dfa8 to
e64adb7
Compare
Co-authored-by: Diego Sampaio <chinello@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.changeset/young-humans-stare.md
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-11-19T12:32:29.696Z
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 37547
File: packages/i18n/src/locales/en.i18n.json:634-634
Timestamp: 2025-11-19T12:32:29.696Z
Learning: Repo: RocketChat/Rocket.Chat
Context: i18n workflow
Learning: In this repository, new translation keys should be added to packages/i18n/src/locales/en.i18n.json only; other locale files are populated via the external translation pipeline and/or fall back to English. Do not request adding the same key to all locale files in future reviews.
Applied to files:
.changeset/young-humans-stare.md
📚 Learning: 2025-11-10T19:06:20.146Z
Learnt from: MartinSchoeler
Repo: RocketChat/Rocket.Chat PR: 37408
File: apps/meteor/client/views/admin/ABAC/useRoomAttributeOptions.tsx:53-69
Timestamp: 2025-11-10T19:06:20.146Z
Learning: In the Rocket.Chat repository, do not provide suggestions or recommendations about code sections marked with TODO comments. The maintainers have already identified these as future work and external reviewers lack the full context about implementation plans and timing.
Applied to files:
.changeset/young-humans-stare.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: 📦 Build Packages
- GitHub Check: CodeQL-Build
- GitHub Check: CodeQL-Build
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.changeset/young-humans-stare.md:
- Around line 2-3: The changeset currently marks '@rocket.chat/models' and
'@rocket.chat/meteor' as 'patch' but the addition of a TTL index is a
data-destructive feature and must be surfaced as at least a 'minor' (or 'major')
bump; update the .changeset entry to use 'minor' (or 'major' if you prefer the
stronger signal) for those package entries so releases and release notes
highlight the automatic one‑year expiry change and operators are warned.
The
rocketchat_statisticscollection grows indefinitely as statistics are collected daily but never cleaned up.Customer reported: After running since 2017 (~7 years), their statistics collection reached 496MB - larger than their messages collection (454MB).
Proposed changes (including videos or screenshots)
This PR adds a MongoDB TTL index to automatically expire statistics documents after 1 year (365 days), capping storage to approximately ~70MB regardless of how long the server runs.
Why TTL index?
Issue(s)
Steps to test or reproduce
db.rocketchat_statistics.getIndexes(){ "key": { "createdAt": 1 }, "name": "createdAt_1", "expireAfterSeconds": 31536000 }Further comments
Alternatives considered:
Important: in the future, when we reach the next major, we should merge PR #38572. It contains the index consolidation and a migration that we can’t merge right now, since migrations are only included in major releases. The work there is ready to go.
Summary by CodeRabbit
New Features
Chores