[FIX] Corrected timefield comparison for message retention policy cron#11725
[FIX] Corrected timefield comparison for message retention policy cron#11725TheReal1604 wants to merge 1 commit intoRocketChat:developfrom TheReal1604:prune-cronjob-timefield
Conversation
|
Hmmm, I'm not so sure about this. Basically, the current logic skips all channels that have not been touched since the last prune, to save processing power. Changing the checked field to Perhaps the |
|
Rereading everything, I understand your misconception more. You are operating on the grounds that the algorithm skips channels which are younger than the prune timer. Which is logical, in fact - we could totally have added that by filtering to channels where However, this algorithm instead compares a timestamp of the last prune ( I feel the best option here is a cleanly documented |
|
Thanks for your explanation @vynmera I was not aware that changing the field to ts leads to cleaning once - but with your explanation and viewing again on the code this makes absolutely sense. For me the Higher Precision switch would be ok - but maybe there is something more elegant and not an additional layer of complexity. 😁
But are you sure the updatedAt field is touched when the server restarts? We definitely have channels which doesnt get this update at a server restart.
|
|
@TheReal1604 The reason the prune goes through when the server restarts is that after a restart, the As for the statistics, I believe those are mainly just tallying counters. They're one-way, I believe. If you want an exact count of the amount of messages, connect to the mongo and run |
@vynmera I think it would be better to compare the room "ts" timefield not the _updatedAt field for various reasons:
If a users change the name or description of the channel the _updatedAt field is touched and the messages in this channel gets not cleared
I found this issue after enabling the retention policy for our system with 365 days retention time - but it doesnt clean any messages. If I take the manual wizard it is cleaning messages.
The ground zero for this is, we migrated our instance to LDAP and renamed ALL user accounts - this results in that the _updatedAt field of all channels got updated - unfortunately this timefield is now not older than the 365 days, but messages in it are older than that.