Skip to content

Commit

Permalink
break the loop if context is cancelled (#4476)
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Elliott <number101010@gmail.com>
  • Loading branch information
joe-elliott authored Dec 19, 2024
1 parent fa9b7ad commit 0aecee5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tempodb/compactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,12 @@ func (rw *readerWriter) compactionLoop(ctx context.Context) {
compactionCycle = rw.compactorCfg.CompactionCycle
}

ticker := time.NewTicker(compactionCycle)
defer ticker.Stop()
for {
// if the context is cancelled, we're shutting down and need to stop compacting
if ctx.Err() != nil {
break
}

doForAtLeast(ctx, compactionCycle, func() {
rw.compactOneTenant(ctx)
})
Expand Down

0 comments on commit 0aecee5

Please sign in to comment.