Repair MongoDB Database & Reduce Database Size

Hi @Rajan,

It is possible to reduce the size of the MongoDB database by using the compact command, but please note this is a blocking command; cryoSPARC will not work while this command is running.
MongoDB does not release storage space back to the OS when you delete documents, which is why the storage size remains the same.

First, create a backup of your database.
Then, in a shell on the master node:

  1. cryosparcm restart
  2. eval $(cryosparcm env)
  3. mongo localhost:$CRYOSPARC_MONGO_PORT # will create a db shell
    use meteor
    db.stats()
    db.runCommand({compact:'projects', force: true})
    db.runCommand({compact:'workspaces', force: true})
    db.runCommand({compact:'jobs', force: true})
    db.runCommand({compact:'users', force: true})
    db.runCommand({compact:'cache_files', force: true})
    db.runCommand({compact:'events', force: true})
    db.runCommand({compact:'file_index', force: true})
    db.runCommand({compact:'fs.chunks', force: true})
    db.runCommand({compact:'fs.files', force: true})
    db.runCommand({compact:'int_curate_exposures', force: true})
    db.runCommand({compact:'notifications', force: true})
    db.stats()
    

You can compare the difference in size using the output of the db.stats() command.
For more information on the compact command, see: https://docs.mongodb.com/v3.4/reference/command/compact/
and
https://www.alibabacloud.com/blog/lets-talk-about-mongodbs-compact-command_595540

Also, to answer your second question, no, deleting a user does not delete any other associated information.

4 Likes