Maksim Kondratyuk
Maksim Kondratyuk

Reputation: 1399

MongoDB oplog contains many Noops

I am trying to improve the oplog of my MongoDB server, because for now it's covering less hours, than I would like (I am not planning to increase oplog file size for now). What I found that there are many noops records in the oplog collection - { "op": "n" } + the whole document on "o". And they could take about ~20%-30% of the physical oplog size.

How could I find the reason for that, because it seems to be not ok ?

We are using MongoDB 3.6 + NodeJS 10 + Mongoose

p.s. it appears for many different collection and use cases, so it's hard to understand what is a application logic behind all these items.

Upvotes: 4

Views: 1398

Answers (1)

Stennie
Stennie

Reputation: 65363

No-op writes are expected in a MongoDB 3.4+ replica set in order to support the Max Staleness specification that helps applications avoid reading from stale secondaries and provides a more accurate measure of replication lag. These no-op writes only happen when the primary is idle. The idle write interval is not currently configurable (as at MongoDB 4.2).

The Max Staleness specification includes an example scenario and more detailed rationale for why the Primary must write periodic no-ops as well as other design decisions.

A relevant excerpt from the design rationale:

An idle primary must execute a no-op every 10 seconds (idleWritePeriodMS) to keep secondaries' lastWriteDate values close to the primary's clock. The no-op also keeps opTimes close to the primary's, which helps mongos choose an up-to-date secondary to read from in a CSRS.

Monitoring software like MongoDB Cloud Manager that charts replication lag will also benefit when spurious lag spikes are solved.

Upvotes: 5

Related Questions