diff --git a/cmd/thanos/compact.go b/cmd/thanos/compact.go index b026dbec99..f38a5cafd8 100644 --- a/cmd/thanos/compact.go +++ b/cmd/thanos/compact.go @@ -44,6 +44,11 @@ func registerCompact(m map[string]setupFunc, app *kingpin.Application, name stri wait := cmd.Flag("wait", "Do not exit after all compactions have been processed and wait for new work."). Short('w').Bool() + // TODO(bplotka): Remove this flag once https://github.com/improbable-eng/thanos/issues/297 is fixed. + disableDownsampling := cmd.Flag("debug.disable-downsampling", "Disables downsampling. This is not recommended " + + "as querying long time ranges without non-downsampled data is not efficient and not useful (is not possible to render all for human eye)."). + Hidden().Default("false").Bool() + m[name] = func(g *run.Group, logger log.Logger, reg *prometheus.Registry, tracer opentracing.Tracer, _ bool) error { return runCompact(g, logger, reg, *httpAddr, @@ -55,6 +60,7 @@ func registerCompact(m map[string]setupFunc, app *kingpin.Application, name stri *wait, time.Duration(*retention), name, + *disableDownsampling, ) } } @@ -72,6 +78,7 @@ func runCompact( wait bool, retention time.Duration, component string, + disableDownsampling bool, ) error { halted := prometheus.NewGauge(prometheus.GaugeOpts{ Name: "thanos_compactor_halted", @@ -131,20 +138,27 @@ func runCompact( if err := compactor.Compact(ctx); err != nil { return errors.Wrap(err, "compaction failed") } + level.Info(logger).Log("msg", "compaction iterations done") - // After all compactions are done, work down the downsampling backlog. - // We run two passes of this to ensure that the 1h downsampling is generated - // for 5m downsamplings created in the first run. - level.Info(logger).Log("msg", "start first pass of downsampling") + // TODO(bplotka): Remove "disableDownsampling" once https://github.com/improbable-eng/thanos/issues/297 is fixed. + if !disableDownsampling { + // After all compactions are done, work down the downsampling backlog. + // We run two passes of this to ensure that the 1h downsampling is generated + // for 5m downsamplings created in the first run. + level.Info(logger).Log("msg", "start first pass of downsampling") - if err := downsampleBucket(ctx, logger, bkt, downsamplingDir); err != nil { - return errors.Wrap(err, "first pass of downsampling failed") - } + if err := downsampleBucket(ctx, logger, bkt, downsamplingDir); err != nil { + return errors.Wrap(err, "first pass of downsampling failed") + } - level.Info(logger).Log("msg", "start second pass of downsampling") + level.Info(logger).Log("msg", "start second pass of downsampling") - if err := downsampleBucket(ctx, logger, bkt, downsamplingDir); err != nil { - return errors.Wrap(err, "second pass of downsampling failed") + if err := downsampleBucket(ctx, logger, bkt, downsamplingDir); err != nil { + return errors.Wrap(err, "second pass of downsampling failed") + } + level.Info(logger).Log("msg", "downsampling iterations done") + } else { + level.Warn(logger).Log("msg", "downsampling was explicitly disabled") } if retention.Seconds() != 0 { @@ -152,7 +166,7 @@ func runCompact( return errors.Wrap(err, "retention failed") } } - level.Info(logger).Log("msg", "compaction, downsampling and optional retention apply iteration done") + return nil }