pebble fix

This commit is contained in:
N 2025-07-24 00:21:49 +08:00
parent 16117eb7cd
commit b46a4c7772

View file

@ -18,6 +18,7 @@
package pebble package pebble
import ( import (
"errors"
"fmt" "fmt"
"runtime" "runtime"
"strings" "strings"
@ -121,13 +122,15 @@ func (d *Database) onCompactionBegin(info pebble.CompactionInfo) {
} }
func (d *Database) onCompactionEnd(info pebble.CompactionInfo) { func (d *Database) onCompactionEnd(info pebble.CompactionInfo) {
if d.activeComp == 1 { switch d.activeComp {
case 1:
d.compTime.Add(int64(time.Since(d.compStartTime))) d.compTime.Add(int64(time.Since(d.compStartTime)))
} else if d.activeComp == 0 { case 0:
panic("should not happen") panic("should not happen")
} default:
d.activeComp-- d.activeComp--
} }
}
func (d *Database) onWriteStallBegin(b pebble.WriteStallBeginInfo) { func (d *Database) onWriteStallBegin(b pebble.WriteStallBeginInfo) {
d.writeDelayStartTime = time.Now() d.writeDelayStartTime = time.Now()
@ -690,24 +693,25 @@ func (b *batch) Replay(w ethdb.KeyValueWriter) error {
} }
// The (k,v) slices might be overwritten if the batch is reset/reused, // The (k,v) slices might be overwritten if the batch is reset/reused,
// and the receiver should copy them if they are to be retained long-term. // and the receiver should copy them if they are to be retained long-term.
if kind == pebble.InternalKeyKindSet { switch kind {
case pebble.InternalKeyKindSet:
if err = w.Put(k, v); err != nil { if err = w.Put(k, v); err != nil {
return err return err
} }
} else if kind == pebble.InternalKeyKindDelete { case pebble.InternalKeyKindDelete:
if err = w.Delete(k); err != nil { if err = w.Delete(k); err != nil {
return err return err
} }
} else if kind == pebble.InternalKeyKindRangeDelete { case pebble.InternalKeyKindRangeDelete:
// For range deletion, k is the start key and v is the end key // For range deletion, k is the start key and v is the end key
if rangeDeleter, ok := w.(ethdb.KeyValueRangeDeleter); ok { if rangeDeleter, ok := w.(ethdb.KeyValueRangeDeleter); ok {
if err = rangeDeleter.DeleteRange(k, v); err != nil { if err = rangeDeleter.DeleteRange(k, v); err != nil {
return err return err
} }
} else { } else {
return fmt.Errorf("ethdb.KeyValueWriter does not implement DeleteRange") return errors.New("ethdb.KeyValueWriter does not implement DeleteRange")
} }
} else { default:
return fmt.Errorf("unhandled operation, keytype: %v", kind) return fmt.Errorf("unhandled operation, keytype: %v", kind)
} }
} }