dermesser / leveldb-rs

A reimplementation of LevelDB in Rust (no bindings).
Other
515 stars 60 forks source link

fix bug: largest key of sstable is the last key inserted into the table #29

Closed EmoFuncs closed 1 year ago

EmoFuncs commented 1 year ago

Some information (FileMetaData) of the new table is collected when compacting the tables, including the largest key of the table. In the original c++ code, the largest key is updated whenever a new (key, value) pair is inserted into the table. In here, however, it is only updated once when a table is finished. The author may try to avoid unnecessary copy of keys. But in some case, it will make the next key (which may be the smallest key of the next table) to be the largest key of the previous table. This violate the assert statement that adjacent tables do not overlap. Changing back to the original implemetation, the bug is fixed.