RocketChat / RocketChat/Rocket.Chat

[Bug] Retention Policy deletes entire Discussion if it started before prune date

Open
#19,269 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
46.1k
Forks
13.9k
Avg merge
3d 3h
Merged PRs (30d)
130

Description

Description:

Retention Policy deletes entire Discussion if it started before prune date even if that Discussion have a lot of recent messages that not affected by Retention Policy

@sampaiodiego please take a look at that issue.
@bseclier first informed me about that behavior here

Steps to reproduce:
  1. Create Discussion e.g. at 1 of October and write a messages every day till now (until 16 of October included)
  2. Set Retention Policy to prune all messages in all type of chats starting e.g. 10th of October
  3. Discussion will be deleted entirely
Expected behavior:

All messages in Discussion since prune date (10 of October in example) should be remain in Discussion, and Discussion itself should not be deleted.

Actual behavior:

Discussion is gone with recent messages

Server Setup Information:
  • Version of Rocket.Chat Server: 3.6.3
  • Operating System: CentOS7
  • Deployment Method: docker
  • Number of Running Instances: 25
  • DB Replicaset Oplog: Enabled
  • NodeJS Version: v12.16.0
  • MongoDB Version: 4.0.17
Client Setup Information
  • Desktop App or Browser Version: Chrome 85
  • Operating System: Windows 10
Additional context

Discussion should be fully deleted if all it's messages older then prune date (all made before 10 of October in example).
And it is true for all type of chats:

  • Entire chat should be deleted of all it's messages are older then prune date
  • Chat should remain it it have recent messages after prune date
Relevant logs:

server.js:204 Meteor ➔ method stream -> userId: null, arguments: ["notify-room","MvxB43F435T2FC2RuZD9QSjhLJiMQ5PRfS/deleteMessageBulk",{"0":{"rid":"MvxB43F435T2FC2RuZD9QSjhLJiMQ5PRfS","excludePinned":false,"ignoreDiscussion":false,"ts":{"$gte":"0001-01-01T00:00:00.000Z","$lte":"2020-08-01T09:00:00.838Z"},"users":[]}}]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the retention-policy behavior described in the reproduction and trace the server.js:204 deleteMessageBulk log entry. Done means pruning removes only messages before the cutoff, while discussions and chats with newer messages remain; fully old chats may still be deleted.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, typescript
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.