timshannon / badgerhold

BadgerHold is an embeddable NoSQL store for querying Go types built on Badger
MIT License
514 stars 52 forks source link

Issue: Not able to open DB for read only #99

Open PD-Pramila opened 1 year ago

PD-Pramila commented 1 year ago

I set the read only option but still it says can not lock the dir. I want to open DB for one write process and multiple read processes. Is it supported?

tauraamui commented 11 months ago

By default BadgerDB uses a lock to prevent more than one process from accessing the DB, regardless if it's for reading or writing. I'd recommend using a single service instance (this will limit horizontal scalability unfortunately) and just have different internal goroutines for the various read or write jobs.

I'm in the middle of creating an instance/network accessible "wrapper" DB around BadgerDB called Redpanda that uses https://github.com/tauraamui/kvs underneath to facilitate the data storage and loading, but until I release that the above is what I recommend.