Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 为什么rockdb里的level 0存在重复key,level 1及以后的N就没有
There is duplicate data in the level 0 SST file, I don’t understand why.
Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 为什么rockdb里的level 0存在重复key,level 1及以后的N就没有
There is duplicate data in the level 0 SST file, I don’t understand why.
Secondly, RocksDB is based on the LSM tree engine, and the write process is as shown in the figure above. When writing, data is directly appended to the memtable. Once the memtable is full, it becomes an immutable memtable. During the writing process, operations such as adding 2 to key ‘a’ and deleting 2 may occur, resulting in two separate records being written.
Then, the LSM tree will perform compaction, which is divided into two types:
Therefore, the L0 level may contain duplicates and be unordered, while levels from L1 downward are ordered.
The key contains the TSO time, so how can it be duplicated? Adding first and then deleting, the TSO is different, so it’s not a duplication.
TSO does not guarantee non-duplicate data. It is just a sequence identifier for transaction start and commit. It is not a guarantee of non-duplicate data. It is normal for the same key to have different versions in L0.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.