Limit retention in MongoDB Atlas oplog

546 Views Asked by At

I have a small dataset stored in MongoDB Atlas with very low write activity. This yields an oplog window of 1.5 years! I have short retention policies, but if I have essentially a point-in-time restore going back over a year then they aren't much use.

I see that MongoDB Atlas has a setting for minimum oplog window, but is there a way to set a maximum oplog window?

1

There are 1 best solutions below

0
Michael Haren On

The only solution I've come up with is to essentially flush the oplog with nonsense like this:

  1. Use a small loop to insert 100 documents into a new collection `{ value = "hello world" }
  2. Update all the docs a bunch of times with something like value = value + " hello world" until they are large, e.g. 10MB
  3. Update all the docs with a simple update to further spam the oplog with nonsense like value = value + "!"

In about 10 minutes, including figuring out the commands to do all that, I was able to reduce my oplog time from 2 years to 2 hours. But of course it is now growing again...

Obviously this is absurd and not a good path forward .