tikv / titan

A RocksDB plugin for key-value separation, inspired by WiscKey.
https://pingcap.com/blog/titan-storage-engine-design-and-implementation/
Apache License 2.0
489 stars 165 forks source link

BlobIndex will be broken and failed to decode when zero-terminated in blob handle in compaction filter #321

Open mzygQAQ opened 4 months ago

mzygQAQ commented 4 months ago

https://github.com/tikv/titan/blob/ecaa9ecda94443a183e7361669ca35f8e17c6c7d/src/compaction_filter.h#L73

Slice(const char* s) will step foward util met '\0', it will broken the the blob index and DecodeFrom will be failed.

Connor1996 commented 4 months ago

Yes, seems should use value directly. Would you like to fix it?

mzygQAQ commented 4 months ago

@Connor1996 It seems that fixing it or not does not affect the correctness of tikv/titan. O^O ! Filenumber/offset/length is encoded using varints. Due to the nature of varints, only when the value is 0 will the encoded byte contain 0. Due to the file header, filenumber/offset/length in titan cannot be 0. I encountered this error because I added something else in blobIndex in my version ~~