dgraph-io / badger

Fast key-value DB in Go.
https://dgraph.io/badger
Apache License 2.0
13.88k stars 1.18k forks source link

[QUESTION]: What is managed mode? #1947

Closed firelizzard18 closed 1 year ago

firelizzard18 commented 1 year ago

Question.

What is managed mode? Badger's documentation mentions that various methods "should only be used with managed DB" but I cannot find any information at all about what "managed DB" means. I think it might have something to do with dgraph but that doesn't tell me much. As far as I can tell, "managed mode" can be used to view a past version of the database, which would be extremely useful to me, but I can't find anything about how to use it.

mangalaman93 commented 1 year ago

Find the docs here https://pkg.go.dev/github.com/dgraph-io/badger#OpenManaged closing the issue, feel free to reopen it if needed.

firelizzard18 commented 1 year ago

OpenManaged returns a new DB, which allows more control over setting transaction timestamps, aka managed mode.

This does not tell me anything about how to use managed mode, what it's good for, what its limitations are, or anything like that. What would be most useful to me is something explaining the mechanics of timestamps, or ideally some examples. Timestamps are mentioned in various places but I can't find anything about how they work.

mangalaman93 commented 1 year ago

you are right, we don't have a great explanation for managed mode. This is the mode we use in Dgraph and allows you to control timestamps (logical) yourself for the data that you are writing to badger. You should give it a try and use the functions that are designed for managed mode. If you have specific questions, I would be happy to answer them. If you are having troubles trying it out, you can post that here too.

firelizzard18 commented 1 year ago

@mangalaman93 Can I list timestamps? I believe NewTransactionAt will allow me to view a past state of the database? If I want to revert to a past state, is there a more efficient way than using NewTransactionAt, cloning the entire database, and replacing the original with the clone?

mangalaman93 commented 1 year ago

I think either do that, or you can delete all the data that you do not want.