RocketChat / Rocket.Chat

The communications platform that puts data protection first.
https://rocket.chat/
Other
39.34k stars 10.09k forks source link

Each launch job of the Retention Policy changes the state of the room in the database #27956

Open shevchukma opened 1 year ago

shevchukma commented 1 year ago

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:

  1. Enable Retention Policy.
  2. For clarity, set "Use Advanced Retention Policy Cron" to every 5 minutes */5 * * * *
  3. 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:

Client Setup Information

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.

iMiKED commented 1 year ago

I can confirm - after deleting old messages on server side, contacts moving to top of CL by self. This is very strange and unsuspected behaviour.