Snapshot range scan
drmingdrmer opened this issue · 1 comments
Hi Spacejam,
I am a developer from https://github.com/datafuselabs/databend and we has been using sled
to store meta-data of the databend-DB cluster. As an embedded high performance kv store, sled
fits our needs very well.
Except that in some cases, we need to retrieve a list of key-value pairs, such as a bunch of users.
It would be very nice If sled
is able to provide a way to create snapshot view for an application to repeatedly scan it and get the same response.
Is it possible to add such a feature to sled
?
And we'd be glad to help on this:DDD
Use Case:
Meta data of a database cluster.
It stores database
, table
, schema
.
Proposed Change:
Range scan on a snapshot view. E.g.:
let s = db.snapshot();
// Expect a snapshot always returns the same result no matter if other key-values are added or removed.
let prev_res = s.range(..);
db.insert(b"a", b"b");
db.remove(b"c", b"d");
assert_eq!(s.range(..), prev_res);
Who Benefits From The Change(s)?
The https://github.com/datafuselabs/databend team and some other guys :D
Alternative Approaches
Add a RWLock to contain the sled db, to prevent writes during db.range(..)
.
Related, it would be great to be able to atomically read a snapshot of the database, and start a subscription that sees changes from that snapshot onward.