Question
The connector setup testsfail and report that you do not have 24 hours worth of oplogs. The following error appears: Oplog has no entries.
Environment
Connector: MongoDB
Answer
There is no variable to control the length of time in Mongo versions below 4.4; only the size. You must extrapolate the length of time based on the size. For more information, please visit MongoDB's guide to changing the oplog size in their 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);
We compare the two timestamps to determine if 24 hours' worth of logs are available.
New in version 4.4: MongoDB 4.4 supports specifying a minimum oplog retention period in hours, where MongoDB only removes an oplog entry if:
- The oplog has reached the maximum configured size, and
- The oplog entry is older than the configured number of hours.
Cause
The oldest and newest oplog entries are not 24 hours apart.