@@ -1152,8 +1152,8 @@ type Options struct {
11521152 // This value is only a best-effort target; the effective rate can be
11531153 // higher if deletions are falling behind or disk space is running low.
11541154 //
1155- // Setting this to 0 disables deletion pacing, which is also the default.
1156- TargetByteDeletionRate int
1155+ // A returned value of 0 disables deletion pacing (this is also the default) .
1156+ TargetByteDeletionRate func () int
11571157
11581158 // FreeSpaceThresholdBytes specifies the minimum amount of free disk space that Pebble
11591159 // attempts to maintain. If free disk space drops below this threshold, deletions
@@ -1511,6 +1511,10 @@ func (o *Options) EnsureDefaults() {
15111511 o .Cleaner = DeleteCleaner {}
15121512 }
15131513
1514+ if o .TargetByteDeletionRate == nil {
1515+ o .TargetByteDeletionRate = func () int { return 0 }
1516+ }
1517+
15141518 if o .FreeSpaceThresholdBytes == 0 {
15151519 o .FreeSpaceThresholdBytes = 16 << 30 // 16 GB
15161520 }
@@ -1797,7 +1801,7 @@ func (o *Options) String() string {
17971801 fmt .Fprintf (& buf , " max_open_files=%d\n " , o .MaxOpenFiles )
17981802 fmt .Fprintf (& buf , " mem_table_size=%d\n " , o .MemTableSize )
17991803 fmt .Fprintf (& buf , " mem_table_stop_writes_threshold=%d\n " , o .MemTableStopWritesThreshold )
1800- fmt .Fprintf (& buf , " min_deletion_rate=%d\n " , o .TargetByteDeletionRate )
1804+ fmt .Fprintf (& buf , " min_deletion_rate=%d\n " , o .TargetByteDeletionRate () )
18011805 fmt .Fprintf (& buf , " free_space_threshold_bytes=%d\n " , o .FreeSpaceThresholdBytes )
18021806 fmt .Fprintf (& buf , " free_space_timeframe=%s\n " , o .FreeSpaceTimeframe .String ())
18031807 fmt .Fprintf (& buf , " obsolete_bytes_max_ratio=%f\n " , o .ObsoleteBytesMaxRatio )
@@ -2168,7 +2172,11 @@ func (o *Options) Parse(s string, hooks *ParseHooks) error {
21682172 // Do nothing; option existed in older versions of pebble, and
21692173 // may be meaningful again eventually.
21702174 case "min_deletion_rate" :
2171- o .TargetByteDeletionRate , err = strconv .Atoi (value )
2175+ var rate int
2176+ rate , err = strconv .Atoi (value )
2177+ if err == nil {
2178+ o .TargetByteDeletionRate = func () int { return rate }
2179+ }
21722180 case "free_space_threshold_bytes" :
21732181 o .FreeSpaceThresholdBytes , err = strconv .ParseUint (value , 10 , 64 )
21742182 case "free_space_timeframe" :
0 commit comments