From d1d438ff0b703551a65d2898c15270cfb9799088 Mon Sep 17 00:00:00 2001 From: Jackson Owens Date: Fri, 22 Aug 2025 14:05:49 -0400 Subject: [PATCH] storage: add cluster setting to use old compaction eligibility In cockroachdb/pebble#5187 we altered the default compaction picking logic that determines whether a level is elgible for a default compaction. We added a knob to allow the configuration of this value at runtime in case the change has some unforeseen impact on some workloads. This commit connects this knob to a new cluster setting. This cluster setting is just an escape hatch that we don't anticipate needing. Epic: none Release note: none --- pkg/storage/pebble.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pkg/storage/pebble.go b/pkg/storage/pebble.go index 3c05c61aa072..ce57ba434a5c 100644 --- a/pkg/storage/pebble.go +++ b/pkg/storage/pebble.go @@ -175,6 +175,22 @@ var enableMultiLevelWriteAmpHeuristic = settings.RegisterBoolSetting( true, ) +// useDeprecatedCompensatedScore is a temporary setting that provides a +// mechanism for reverting Pebble's compaction picking heuristic to the previous +// (25.3 and earlier) behavior for deciding when a level is eligible for +// compaction. See the pebble.Options Experimental UseDeprecatedCompensatedScore +// setting for details. +// +// We anticipate not needing to use this setting, but it's provided as an escape +// hatch in case the heuristic change has an unforeseen impact on some +// workloads. +var useDeprecatedCompensatedScore = settings.RegisterBoolSetting( + settings.ApplicationLevel, + "storage.use_deprecated_compensated_score", + "If enabled, this setting revert's the storage engine's compaction picking heuristic", + false, +) + // SSTableCompressionProfile is an enumeration of compression algorithms // available for compressing SSTables (e.g. for backup or transport). type SSTableCompressionProfile int64 @@ -894,6 +910,11 @@ func newPebble(ctx context.Context, cfg engineConfig) (p *Pebble, err error) { return int(concurrentDownloadCompactions.Get(&cfg.settings.SV)) } } + if cfg.opts.Experimental.UseDeprecatedCompensatedScore == nil { + cfg.opts.Experimental.UseDeprecatedCompensatedScore = func() bool { + return useDeprecatedCompensatedScore.Get(&cfg.settings.SV) + } + } cfg.opts.EnsureDefaults()