Resync for MongoDB Elastic Deployments

Update (Sept 2016): This article refers to MongoDB Elastic deployments, now called MongoDB Classic on Compose. For the newer MongoDB database deployments on Compose refer to the MongoDB FAQ on Resyncing which covers the much simpler process now in use.

MongoDB users will find a new option on their admin page to help them keep their database size under control today. In the past we've shown how to keep your MongoDB database size in check by altering the padding, capping collections and repairing the database. There's another way though, resyncing. We haven't mentioned it before because we've been making sure you can use the technique.

You can think of a resync, in broad terms, as dropping the databases of a secondary node in a replica set which then forces it to import all existing data from the current primary in that replica set. This method has a similar outcome to doing a db.repairDatabase() but unlike that command, resyncing does not block access to the primary so you can continue to use your database while it is in progress.

You'll need to do a resync twice, first to the secondary and then, after swapping the primary and the secondary, repeating the process with the newly promoted secondary.

To get started, you'll find the resync option on the admin page of your databases. It's an option that's currently only available for Elastic Deployments. Click the button to start the resync and let the job run.

Resync Panel

Once that has finished you then need to change the primary by triggering a step-down – this will take your primary down temporarily and lets your secondary take its place. The previously-primary system will then come up and take its place in the replica set as a secondary.

Change Primary

After this has been successful, repeat the secondary resync. Once that is completed you will be ready to fully enjoy your reclaimed space! If you have any queries or concerns about the Resync process, support@compose.io can answer them.