Search code examples
mongodbmongodb-oplog

What does it mean when the operation of an oplog just has the id?


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?


Solution

  • 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.