From 26aef7368b91b62dfc0fa26c79aea5280987c9a9 Mon Sep 17 00:00:00 2001 From: Ben Donnelly Date: Mon, 4 Dec 2023 11:29:39 +0000 Subject: [PATCH] fix(compactor/retention): fix missing loop in retention and compactor ref https://github.com/grafana/tempo/pull/2296 --- DEVELOPMENT.md | 8 ++++++++ pkg/deepdb/compactor.go | 18 +++++++++++++----- pkg/deepdb/retention.go | 18 +++++++++++++----- 3 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 DEVELOPMENT.md diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md new file mode 100644 index 0000000..a4e3cbe --- /dev/null +++ b/DEVELOPMENT.md @@ -0,0 +1,8 @@ +# Development + +## Prerequisites + + - Go : v1.20+ + - gofumpt - `go install mvdan.cc/gofumpt@latest` + - goimports - `go install golang.org/x/tools/cmd/goimports@latest` + - Docker \ No newline at end of file diff --git a/pkg/deepdb/compactor.go b/pkg/deepdb/compactor.go index e3777b4..9ee57a6 100644 --- a/pkg/deepdb/compactor.go +++ b/pkg/deepdb/compactor.go @@ -85,11 +85,19 @@ func (rw *readerWriter) compactionLoop(ctx context.Context) { } ticker := time.NewTicker(compactionCycle) - select { - case <-ticker.C: - rw.doCompaction(ctx) - case <-ctx.Done(): - return + for { + select { + case <-ctx.Done(): + return + default: + } + + select { + case <-ticker.C: + rw.doCompaction(ctx) + case <-ctx.Done(): + return + } } } diff --git a/pkg/deepdb/retention.go b/pkg/deepdb/retention.go index 8a3bc46..cab4405 100644 --- a/pkg/deepdb/retention.go +++ b/pkg/deepdb/retention.go @@ -32,11 +32,19 @@ import ( // retentionLoop watches a timer to clean up blocks that are past retention. func (rw *readerWriter) retentionLoop(ctx context.Context) { ticker := time.NewTicker(rw.cfg.BlocklistPoll) - select { - case <-ticker.C: - rw.doRetention(ctx) - case <-ctx.Done(): - return + for { + select { + case <-ctx.Done(): + return + default: + } + + select { + case <-ticker.C: + rw.doRetention(ctx) + case <-ctx.Done(): + return + } } }