Oplog update entry without $set and $unset

When there is an update on a document, oplog entry is supposed to generate $set/$unset key and value.
But it seems I am getting another format in 5.0.x.

{
    lsid: {
      id: UUID("cb05cafc-c6e5-499a-904f-70e5f42506ed"),
      uid: Binary(Buffer.from("d2ca1836aaed04eff4b456c51087fcebefbf828ce3769117ac24ba7e0aa04ba5", "hex"), 0)
    },
    txnNumber: Long("1"),
    op: 'u',
    ns: 'io_blitzz.usertable',
    ui: UUID("5430849c-6922-4ecf-a535-cf1d5c804b2c"),
    o: { '$v': 2, diff: { u: { a: 'simple bbb' } } },
    o2: { _id: ObjectId("62a1d82c6ce0604e2a9e1636") },
    ts: Timestamp({ t: 1656074879, i: 2 }),
    t: Long("7"),
    v: Long("2"),
    wall: ISODate("2022-06-24T12:47:59.109Z"),
    stmtId: 0,
    prevOpTime: { ts: Timestamp({ t: 0, i: 0 }), t: Long("-1") },
    postImageOpTime: { ts: Timestamp({ t: 1656074879, i: 1 }), t: Long("7") }
  }

If I check on 4.0.x, it works as expected.

{ "lsid" : { "id" : UUID("439488ea-86e3-407e-bd85-97c84fcf380d"), "uid" : BinData(0,"47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=") }, "txnNumber" : NumberLong(1), "op" : "u", "ns" : "io.usertable", "ui" : UUID("7f1d5ea3-6a83-4fb1-8baa-8e87baa3a8d7"), "o" : { "$v" : 1, "$set" : { "surname" : "a1 caprio" } }, "o2" : { "_id" : ObjectId("62b94beb1a070faf11a9eaf0") }, "ts" : Timestamp(1656312210, 4), "t" : NumberLong(1), "v" : NumberLong(2), "wall" : ISODate("2022-06-27T06:43:30.533Z"), "stmtId" : 0, "prevOpTime" : { "ts" : Timestamp(0, 0), "t" : NumberLong(-1) }, "postImageOpTime" : { "ts" : Timestamp(1656312210, 3), "t" : NumberLong(1) } }

Operations I am doing is update key ‘a’ to another value ‘simple bbb’.
Expected tag o is something like o: { ‘$v’: 2, $set: { a: ‘simple bbb’ } }
But actual value is o: { ‘$v’: 2, diff: { u: { a: ‘simple bbb’ } } }
What is this diff: and u: tag? This seems to be generated in mongo 5.0.x
When I check oplogs on mongo 4.0.x, I can see $set tag as part of o: correctly

Hi @Mandar_Pawar and welcome to the community!!

The oplog format is internal and subject to change. Change Streams is the supported API for observing changes in a MongoDB deployment.
However to answer your question,

diff signifies difference in the old and new field entries.
u signifies the operation type, in this case it would be Update. (there can be others ad d: Delete, i: Insert and so on)

Please refer to the update-operators documentation to understand more on the changes for the oplog in the recent versions.

Let us know if you have any further questions.

Thanks
Aasawari

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