Oplog is growing too much when clock goes back in time

Hi,

For some reason, clock synchronization sometime fails on our servers. In this case, the date can be updated to a date far in the future (eg many years after the real date). Then, the sync get fixed, and the time comes back to the real date.

The oplog has a problematifc behavior in this use case.
We configured oplog max size to the minimum possible value (990Mb). Our replicaset contains only one server.

  • Initially, everything works correctly : as soon as oplog is full, old entries get deleted and oplog size does not exceed 990mb
  • When updating date to the future (T+X), it continues to work correctly
  • Then when updating to the past (T-X), problems starts to appear:
  • First, db.getReplicationInfo() hangs, this is not really an issue but it makes difficult to see what’s going on. oplog.rs.find({}) also hangs.
  • On disk, the oplog.ts collection .wt file grows indefinitely.

It appears that this file will grow until current date reached the maximum oplog date (which is T+X). In our case this means many years.

Is that a normal behavior?
Is there a way to avoid oplog growing indefinitely?