0

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?

  • What version of MongoDB? – Joe Feb 14 '23 at 16:39
  • @Joe Version: 4.4.18 – Felipe Sadoyama Feb 14 '23 at 16:43
  • That might be part of an uncommitted transaction, search the oplog for other instances of that namespace and id to see if you correlate the oplog to what the app was supposed to be doing. – Joe Feb 14 '23 at 16:49
  • I actually found out the problem on my code causing it. Aparently the mongoid ruby gem has a problem where it can generate an update operation that removes every field except for the id from the document. – Felipe Sadoyama Feb 14 '23 at 18:57

2 Answers2

1

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

Joe
  • 25,000
  • 3
  • 22
  • 44
0

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.