Mongodb Atlas compact oplog.rs

Hello,

I am facing some issues with my installation on MongoDB Atlas. I have an M10 cluster with mongo 4.4.

This cluster needs to be configured under minimum requirements, with an M10 and 10GB of space. Something happened and the cluster storage autoscaled to 14GB (i forgot to deactivate the cluster storage autoscaling).

The culprit of the storage consumption was the oplog.rs collection, on the local database. I successfully reduced the size of the oplog collection from the Atlas console (Cluster → Configuration → Additional Settings → More configuration options → set oplog size) and this works, but i’m not able to reclaim the unused space.

The documentation says to perform a compact operation on the oplog collection:

This works on the two secondary replicas i have but the documentation specifically says that this command must not be executed on the primary replica set member. It advices to execute rs.stepDown to choose another primary but this operation is not supported on Mongodb Atlas: https://www.mongodb.com/docs/atlas/unsupported-commands/#replication.

Is there a way to do this on Atlas? I just need to promote a new primary member so i can run compact on the last member of the replicaset.

Thank you in advance!

Hi @Monstruo_Delasgalletas - Welcome to the community :slight_smile:

This works on the two secondary replicas i have but the documentation specifically says that this command must not be executed on the primary replica set member. It advices to execute rs.stepDown to choose another primary but this operation is not supported on Mongodb Atlas

Is there a way to do this on Atlas? I just need to promote a new primary member so i can run compact on the last member of the replicaset.

  1. Once you have completed running compact() on all secondary members in the cluster (which seems as though you have), use the cluster’s Test failover feature to step down the current primary member and wait for them to transition to secondary.
  2. Perform the compact() command again on the remaining member that stepped down.

Hope this helps.

Regards,
Jason

1 Like

Hi @Jason_Tran

Thank you! It worked perfectly. The Test failover process can take some time but it works and changes the primary.

Compacting the primary reduces the size of the oplog as explected. One thing i noticed (if someone finds this thread in the future) is that the size that Atlas counts (“Disk Usage” on the cluster panel) for the storage autoscaler is the primary size. Once changed the primary and compacted i was able to reduce the disk size.

Thanks for your help!

Regards

2 Likes

Thank you! It worked perfectly. The Test failover process can take some time but it works and changes the primary.

No problem and happy to hear that got it sorted :slight_smile:

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.