-
Notifications
You must be signed in to change notification settings - Fork 13.1k
fix: add TTL index to statistics collection for automatic cleanup #38568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
🦋 Changeset detectedLatest commit: 073dfa8 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 |
WalkthroughImplements automatic cleanup of the MongoDB statistics collection by adding a TTL (Time To Live) index that expires documents after 365 days, preventing indefinite growth of the statistics collection over time. 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. No actionable comments were generated in the recent review. 🎉 📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (1)**/*.{ts,tsx,js}📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Files:
🔇 Additional comments (2)
✏️ Tip: You can disable this entire section by setting 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.39% 70.41% +0.01%
===========================================
Files 3161 3162 +1
Lines 110654 110650 -4
Branches 19892 19859 -33
===========================================
+ Hits 77895 77914 +19
+ Misses 30731 30707 -24
- Partials 2028 2029 +1
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 2 files
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
Release Notes
New Features
Chores