Rocket.chat: rocketchat_integration_history becomes too big

Created on 6 Feb 2018  路  4Comments  路  Source: RocketChat/Rocket.Chat

Description:

I noticed that our Rocket.Chat database has become pretty big:

server ~ # du -sh /var/lib/mongodb 
5,3G    /var/lib/mongodb

The main reason for this seems to be the rocketchat_integration_history collection:

rocketchat.rocketchat_integration_history: 2.9 GB (3.0 GB)
rocketchat.rocketchat_uploads.chunks: 685.5 MB (752.9 MB)        
rocketchat.rocketchat_message: 83.1 MB (118.2 MB)               
rocketchat.rocketchat_oembed_cache: 45.0 MB (79.7 MB)  
rocketchat.rocketchat__trash: 23.2 MB (79.8 MB)             
rocketchat.rocketchat_statistics: 14.0 MB (21.5 MB)    
> db.rocketchat_integration_history.stats()
{
        "ns" : "rocketchat.rocketchat_integration_history",
        "count" : 309355,
        "size" : 3108092240,
        "avgObjSize" : 10047,
        "numExtents" : 21,
        "storageSize" : 3189919696,
        "lastExtentSize" : 536600560,
        "paddingFactor" : 1,
        "paddingFactorNote" : "paddingFactor is unused and unmaintained in 3.0. It remains hard coded to 1.0 for compatibility only.",
        "userFlags" : 1,
        "capped" : false,
        "nindexes" : 2,
        "totalIndexSize" : 31600240,
        "indexSizes" : {
                "_id_" : 16082192,
                "_updatedAt_1" : 15518048
        },
        "ok" : 1
}

Apparently it stores every message that has ever passed through an integration and old entries aren't automatically purged :(

In our case this means every message ever, because we have a Redmine integration that looks up Redmine ticket IDs, and it's configured for the channels all_public_channels, all_private_groups, all_direct_messages.

I've looked in the configuration for any way on how to disable this history (we don't need it at all), but apparently there's no way.

Server Setup Information:

  • Version of Rocket.Chat Server: 0.60.3
  • Operating System: Debian stretch
  • Deployment Method(snap/docker/tar/etc): tar
  • Number of Running Instances: 1
  • DB Replicaset Oplog: Disabled
  • Node Version: v8.9.3

Steps to Reproduce:

  1. Set up an integration.
  2. Post a few messages in channels monitored by the integration.
  3. Note how the db.rocketchat_integration_history collection only grows.

Expected behavior:

  • The db.rocketchat_integration_history collection should be automatically pruned to remove older entries.
  • There should be a way to enable/disable the history for specific integrations. I would like it to be disabled by default (as it is, it's also a privacy issue because it allows admins to easily view chat messages that the integration has seen), and it should only be enabled when necessary for debugging.

Actual behavior:

db.rocketchat_integration_history grows to enormous size.

Most helpful comment

db.rocketchat_integration_history.remove({}) worked fine. I've put that into a cronjob:

server /etc/cron.daily # cat _rocketchat_keep_integration_history_empty 
#!/bin/sh

# https://github.com/RocketChat/Rocket.Chat/issues/9617
mongo rocketchat --eval 'db.rocketchat_integration_history.remove({})' --quiet | grep -v '^WriteResult' || true

All 4 comments

In the meantime - is there any way to get rid of the history entries? Is it safe to just empty the whole collection like this?

db.rocketchat_integration_history.deleteMany({})

For now, yes you should be able to drop the database until we implement the options to control how the history works. Which will be soon since we are working on adding history support to incoming integrations.

For now, yes you should be able to drop the database until we implement the options to control how the history works.

So even db.rocketchat_integration_history.drop() would be safe? Wouldn't this remove the whole collection, and not only the containing documents? Does Rocket.Chat then automatically recreate the collection? I'm not very familiar with MongoDB, and I want to be sure that I don't accidentally kill our database :)

db.rocketchat_integration_history.remove({}) worked fine. I've put that into a cronjob:

server /etc/cron.daily # cat _rocketchat_keep_integration_history_empty 
#!/bin/sh

# https://github.com/RocketChat/Rocket.Chat/issues/9617
mongo rocketchat --eval 'db.rocketchat_integration_history.remove({})' --quiet | grep -v '^WriteResult' || true
Was this page helpful?
0 / 5 - 0 ratings

Related issues

antn89 picture antn89  路  3Comments

Buzzele picture Buzzele  路  3Comments

neha1deshmukh picture neha1deshmukh  路  3Comments

sta-szek picture sta-szek  路  3Comments

lunitic picture lunitic  路  3Comments