Skip to content

Commit

Permalink
do not run retention loop when retention is not enabled (#11280)
Browse files Browse the repository at this point in the history
**What this PR does / why we need it**:
Do not run retention loop when retention is not enabled
  • Loading branch information
sandeepsukhani authored Nov 22, 2023
1 parent 6e93d15 commit 162bbb1
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions pkg/compactor/compactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,29 +534,29 @@ func (c *Compactor) runCompactions(ctx context.Context) {
}
}()

c.wg.Add(1)
go func() {
defer c.wg.Done()
if err := c.RunCompaction(ctx, true); err != nil {
level.Error(util_log.Logger).Log("msg", "failed to apply retention", err)
}
if c.cfg.RetentionEnabled {
c.wg.Add(1)
go func() {
defer c.wg.Done()
if err := c.RunCompaction(ctx, true); err != nil {
level.Error(util_log.Logger).Log("msg", "failed to apply retention", err)
}

ticker := time.NewTicker(c.cfg.ApplyRetentionInterval)
defer ticker.Stop()
ticker := time.NewTicker(c.cfg.ApplyRetentionInterval)
defer ticker.Stop()

for {
select {
case <-ticker.C:
if err := c.RunCompaction(ctx, true); err != nil {
level.Error(util_log.Logger).Log("msg", "failed to apply retention", err)
for {
select {
case <-ticker.C:
if err := c.RunCompaction(ctx, true); err != nil {
level.Error(util_log.Logger).Log("msg", "failed to apply retention", err)
}
case <-ctx.Done():
return
}
case <-ctx.Done():
return
}
}
}()
}()

if c.cfg.RetentionEnabled {
for _, container := range c.storeContainers {
c.wg.Add(1)
go func(sc storeContainer) {
Expand Down

0 comments on commit 162bbb1

Please sign in to comment.