How are opcountersRepl different from opcounters?

The web page:
says serverStatus.opcountersRepl:

reports on database replication operations

Is that on the primary and the replicate? What database replication operations are there on the primary? Are opcountersRepl a superset of opcounters?

But then the same web page says:

These values will differ from the [opcounters values because of how MongoDB serializes operations during replication.

So is a logical operation (eg. delete a set of rows) counted once in in opcounters, but then counted once for each row if the operation is serialized into multiple single row deletes?

Hi @Benjamin_Slade,

The opcounters values, for CRUD operations, will be the number of operations that happen when the node is the PRIMARY node for the replica set. The opcountersRepl values, for CRUD operations, will be the number of replicated commands that were run when the node was acting as a SECONDARY member. You might see values in both of these sections on a single node due to the fact that a node can be promoted from a SECONDARY to PRIMARY should there be a reason for an election.

Note that a single command on the PRIMARY could trigger multiple commands on the SECONDARY node. This is due to the fact that the replicated commands in the oplog will have a single command for each document that was affected on the PRIMARY.

These counters are reset when the mongod process is restarted, so they only show numbers since the last service restart.


Thanks for the clear, concise answer. My only gripe is, I wish this was in the documentation.

I’m glad that helped you out @Benjamin_Slade. One thing to note is that the documentation is a github project that accepts pull requests, so if you find errors or things that don’t make sense you can help make the docs better. :wink:

Each documentation page has an edit icon (image ) in the upper right hand corner that will take you to the page for editing and allow you to submit that change for review. You do have to know restructured text formatting, but that’s not that hard to figure out.


See my github pull request at:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.