File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 2020package pebble
2121
2222import (
23+ "bytes"
2324 "fmt"
2425 "runtime"
2526 "sync"
@@ -361,6 +362,17 @@ func (d *Database) Stat(property string) (string, error) {
361362// is treated as a key after all keys in the data store. If both is nil then it
362363// will compact entire data store.
363364func (d * Database ) Compact (start []byte , limit []byte ) error {
365+ // There is no special flag to represent the end of key range
366+ // in pebble(nil in leveldb). Use an ugly hack to construct a
367+ // large key to represent it.
368+ // Note any prefixed database entry will be smaller than this
369+ // flag, as for trie nodes we need the 32 byte 0xff because
370+ // there might be a shared prefix starting with a number of
371+ // 0xff-s, so 32 ensures than only a hash collision could touch it.
372+ // https://github.com/cockroachdb/pebble/issues/2359#issuecomment-1443995833
373+ if limit == nil {
374+ limit = bytes .Repeat ([]byte {0xff }, 32 )
375+ }
364376 return d .db .Compact (start , limit , true ) // Parallelization is preferred
365377}
366378
You can’t perform that action at this time.
0 commit comments