The Oplog Has No Entries
Question
The connector setup tests fail and report that you do not have 24 hours worth of oplogs. The following error appears: Oplog has no entries
.
Environment
Connector: MongoDB
Answer
In MongoDB versions below 4.4, you can only control the size of the oplog. There is no variable to control the duration of time for which the data is stored. You must extrapolate the duration of time based on the size of the oplog. For more information, see MongoDB's documentation.
The connector setup tests run these two commands to determine if 24 hours of oplog are available:
db.oplog.rs.find().sort({$natural: -1}).limit(1);
db.oplog.rs.find().sort({$natural: 1}).limit(1);
MongoDB 4.4 supports specifying a minimum oplog retention period in hours.
In this version, MongoDB only removes an oplog entry if:
- It has reached the maximum configured size, and
- It is older than the configured number of hours.
Cause
The oldest and newest oplog entries are not 24 hours apart.