Does read-only Txn always reflect the latest view?

What version of Go are you using (go version)?

$ go version
go version go1.15.1 linux/amd64

What operating system are you using?


What version of Badger are you using?


Does this issue reproduce with the latest master?


Steps to Reproduce the issue

What Badger options were set?

What did you do?

This is just a question, I was using a read-only Txn out of a badger db.
My question is: after some other goroutine modifies the same db (probably using another Txn or WriteBatch), can I get the modified dataset from the old read-only Txn, or I need to create a fresh Txn (for that purpose)?


What did you expect to see?

What did you see instead?

Hi @yangzh, Badger ensures that you get a consistent view of the database within a transaction closure. Any writes that happen elsewhere after the transaction has started, will not be seen by calls made within the closure. So to get a fresh view of your database, you will need to create a new transaction. I believe this has answered your query.