Transaction Logging

Hi, is there a way to find what happens for an X document on the X date?
I am trying to find out when the document was modified and what was modified.
Thanks.

Hi @Ed_Durguti,

If you are running a Replica Set and if your oplog window is large enough, you can search in the collection local.oplog.rs based on the _id of this document and you will find the latest operations if they haven’t been overwritten already.

Cheers,
Maxime.

@MaBeuLux88,
Thanks for your reply. I am running the DB in Atlas. Sorry forgot to mention. Is it possible to get these kind of logs from Atlas?

Hi @Ed_Durguti,

Yes of course!
MongoDB on Atlas is like MongoDB anywhere else, it’s the same thing.

use local
db.oplog.rs.find()

But you’ll probably want to filter, depending what you are looking for.

You will probably also need to check the size of your Oplog Window. The more you write (Insert / Update / Delete) docs, the smaller the window. Here is an example of my Open Data COVID Project:

Atlas pre-prod-shard-0 [primary] local> rs.printReplicationInfo()
actual oplog size
'10000 MB'
---
configured oplog size
'10000 MB'
---
log length start to end
'23828 secs (6.62 hrs)'
---
oplog first event time
'Mon Dec 12 2022 13:07:13 GMT+0100 (Central European Standard Time)'
---
oplog last event time
'Mon Dec 12 2022 19:44:21 GMT+0100 (Central European Standard Time)'
---
now
'Mon Dec 12 2022 19:44:24 GMT+0100 (Central European Standard Time)'

As you can see here, my window is quite short because I clear and reimport everything every 4 hours.

If you want, you can enlarge the oplog size in the cluster configuration in the Additional Options > More Configuration Options. (I already did that for this particular cluster for instance).

Cheers,
Maxime.

Hey @MaBeuLux88 I am facing similar issue. I am trying to find why the MongoDb transaction is failing. But when i look at the opLog i don’t see any errors related to the transactions failure. Where can i find this information?

I believe oplog is not for failure information. You should check mongodb server log file.

1 Like