Can I create multiple badger.db instances in multiple go routines?

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

$ go version
go version go1.16.4 darwin/amd6

Does this issue reproduce with the latest master?

Yes.

Hi,

I’m new to BadgerDB. As it’s not mentioned in the documentation, is it possible or recommended to open multiple badger.db instances in multiple go routines? Can read-write transactions from different badger.db instances work properly with each other?

Thank you for your help in advance.

Jonathan Xu

When you open a DB, it acquire lock over the data directory. Hence, you cannot open the multiple instances of same underlying DB. There is an option BypassLockGuard badger/options.go at baadc01dca6e349820ed63fb444ea14fd87cb8b5 · dgraph-io/badger · GitHub that allows skipping taking that lock.
This option is not recommended and should only be used when opening all the instances in ReadOnly mode.