google / google/leveldb

How snapshots retain old data?

Open
#1,038 6 comments 2 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
39.4k
Forks
8.2k
PR merge metrics
No merged PRs in 30d

Description

I am learning leveldb and have some questions about snapshots. The main problem is how to retain the old data that snapshots depend on.
1. I found that the relevant code of the snapshot has nothing to do with the version. It seems that the reference count of a version will not be increased after the snapshot is generated.
2. So I think function DoCompactionWork performed this operation.

Suppose I perform the following operations
```
Put(key1) sequence == 10
Put(key1) sequence == 20
GetSnapshot() sequence == 25
Put(key1) sequence == 30
```

When executing DoCompactionwork, according to the code, is the first key
then `if (last_sequence_for_key <= compact->smallest_snapshot)` looks like to drop ,。
This is wrong with my understanding,I think should be reserved in new Version,Can someone help me answer them?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.