1

I have searched far and wide for all the fields in an oplog but the information is incomplete. I understand its for a term, but what does a term mean? Here is the oplog:

{
    "ts" : Timestamp(1533734637, 2),
    "t" : NumberLong(5),
    "h" : NumberLong("1266644680682122010"),
    "v" : 2,
    "op" : "i",
    "ns" : "mydb.somecollection",
    "ui" : UUID("vxcvzxcvzxcv"),
    "wall" : ISODate("2018-08-08T13:23:57.963Z"),
    "o" : {
        "_id" : UUID("7a007a72-cefe-3102-90b1-927fef7ab8d4"),
        "_sid" : UUID("7a007a72-cefe-3102-90b1-927fef7ab8d4"),
        "generation" : NumberLong(1),
        "expiration" : NumberLong("1533821036856000"),
    }
}
Minh Nguyen
  • 140
  • 7

1 Answers1

3

Since MongoDB v 4.0 we have replication protocol version 1 (pv1). As the documentation of replication internals states:

In the new protocol, PV1, OpTimes also include a term field which indicates how many elections have occurred since the replica set started.

and election is a process to determine which replica set member should become a primary. That will happen when:

  • Adding a new node to the replica set,
  • Initiating a replica set,
  • Performing replica set maintenance using methods such as rs.stepDown() or rs.reconfig()
  • Secondary members losing connectivity to the primary for more than the configured timeout (10 seconds by default).

More about elections here

mickl
  • 48,568
  • 9
  • 60
  • 89
  • Thank you micki for the informative answer and pointing to documentation! If i understand it correctly, does that mean that a 5 in the t means that there has been 5 elections since this oplog has started? – Minh Nguyen Aug 13 '18 at 16:09
  • @MinhNguyen yes, that's how I understand that – mickl Aug 13 '18 at 16:58