RocketChat / RocketChat/Rocket.Chat
Each launch job of the Retention Policy changes the state of the room in the database
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
Description:
This is not a bug, but strange behavior. Every time the task to delete old messages is run, the "_updatedAt" field in the rocketchat_room collection changes.
Is it necessary? Even if no message has been deleted, this field is used to set the task start time. This is done in EVERY document in the rocketchat_room collection, even if no messages have been deleted in the room. We have hundreds of thousands of documents in this collection. Running a Retention Policy will cause a heavy load on the database.
Steps to reproduce:
- Enable Retention Policy.
- For clarity, set "Use Advanced Retention Policy Cron" to every 5 minutes
*/5 * * * * - After 5 minutes, query the database to verify that the "_updatedAt" value has changed in each room:
db.rocketchat_room.find({ }, {"_updatedAt": 1 }).pretty()
Expected behavior:
The "_updatedAt" value in the "rocketchat_room" collection does not change each time the Retention Policy job runs.
Actual behavior:
Each time the Retention Policy job runs, the value of "_updatedAt" in the "rocketchat_room" collection changes.
Server Setup Information:
- Version of Rocket.Chat Server: 5.4.1
- Operating System: Oracle Linux Server release 8.6
- Deployment Method: docker
- Number of Running Instances: 20
- DB Replicaset Oplog: yes
- NodeJS Version: v14.19.3
- MongoDB Version: 5.0.14
Client Setup Information
- Desktop App or Browser Version: Chrome 108
- Operating System: Windows 10
Additional context
By submitting this issue, I am concerned not only with the load on the database. We still have the problem that after running the retention policy job, many chats move up in the contact list. They are sorted by the "_updatedAt" field. I don't quite understand the conditions under which this happens, but I think if the field "_updatedAt" is not updated in such situations, we will get rid of this problem too.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Retention Policy job and the room update path responsible for writes to the rocketchat_room collection. Reproduce the five-minute schedule while observing MongoDB updates and verify whether rooms with no deleted messages are still written. Done means a no-op retention run leaves _updatedAt unchanged and avoids unnecessary database load.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, typescript
- Domain
- backend, databases, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100