skip to Main Content

I am investigating an issue where some data seems to be disappearing and while looking at the oplog of a certain document that fell in the scenario I noticed a weird operation and I am not sure what it means.

{
  lsid: {
    id: new UUID("foo"),
    uid: Binary(Buffer.from("foo", "hex"), 0)
  },
  txnNumber: Long("27"),
  op: 'u',
  ns: 'db.foo',
  o: { _id: ObjectId("foo") },
  o2: { _id: ObjectId("foo") },
  ...
}

What exavtly does o: { _id: ObjectId("foo") } do on the document?

2

Answers


  1. Chosen as BEST ANSWER

    Debugging my code I found out that this operation was indeed the cause of my bug, running an update operation only specifying the _id removes every data from the document except for the _id.

    I found the issue on my code, which is a ruby app using the mongoid gem, that was generating the operation, trying to call model.atomically without passing a block deletes all fields except for the id.


  2. The format of the oplog in undocumented and could be changed between minor versions, so relying on it containing specific data in a certain form is unreliable.

    If you really need to know what that structure means, it will require asking the MongoDB developers or delving into the source code.

    If you just need to know what operations occurred on the node, use Change Streams

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search