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 20
20
package pebble
21
21
22
22
import (
23
+ "bytes"
23
24
"fmt"
24
25
"runtime"
25
26
"sync"
@@ -361,6 +362,17 @@ func (d *Database) Stat(property string) (string, error) {
361
362
// is treated as a key after all keys in the data store. If both is nil then it
362
363
// will compact entire data store.
363
364
func (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
+ }
364
376
return d .db .Compact (start , limit , true ) // Parallelization is preferred
365
377
}
366
378
You can’t perform that action at this time.
0 commit comments