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 + } } }