Closed cbalano closed 5 years ago
This must be some update call bow makes when it's initializing. I'll be checking this later today, and hopefully commit a fix and let you know.
Alright, sounds good; please let me know.
Okay, I think I found the issue -- when you're Open
-ing a brand new database that hasn't been opened before, bow tries to create and store it's meta structure (containing information about buckets) even if it's opened with ReadOnly
.
This same problem happens when you access a bucket that doesn't exist -- bow will try to create it regardless of the ReadOnly
restriction.
Thanks for reporting this issue, I will fix it and let you know.
Excellent. Read-only is a big deal if you access the database from a different process. Inside the same process, one can delegate all Bow operations to a dedicated goroutine and thus avoid dealing with DB locks.
Update: I've set up a read-only test, and I'm fixing stuff until it passes. Will let you know.
@cbalano
Commit 6703512ae74d252b8ffe01e5fcaeb8bbf926b2fe resolves this issue.
You can now Open
with SetReadOnly(true)
and you should be able to read freely, but not write.
Please let me know how it works out for you 😄
Read-only confirmed as working now. Thank you, good sir!
When I attempt to open read-only in a directory that does not exist, I get a panic, rather than an error. Is that the intended behavior?
@cbalano This behaviour is inherited from BadgerDB. Would you prefer to get an error when opening the database instead? Maybe something like ErrNoDatabase
?
Well, it's a nicety, not a must.
When I am trying to open the database in read-only mode, like this: dir := /bow opts := badger.DefaultOptions opts.ReadOnly = true opts.Logger = nil db, err := bow.Open(dir, bow.SetBadgerOptions(opts))
I see:
error: No sets or deletes are allowed in a read-only transaction
From badger docs:
// ErrReadOnlyTxn is returned if an update function is called on a read-only transaction. ErrReadOnlyTxn = errors.New("No sets or deletes are allowed in a read-only transaction")
I update nothing; or am I ?