Skip to content

Commit

Permalink
Merge pull request #76 from intergral/ret_loops
Browse files Browse the repository at this point in the history
fix(compactor/retention): fix missing loop in retention and compactor
  • Loading branch information
Umaaz authored Dec 4, 2023
2 parents 83ad04d + 26aef73 commit 85b6811
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
8 changes: 8 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -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
18 changes: 13 additions & 5 deletions pkg/deepdb/compactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down
18 changes: 13 additions & 5 deletions pkg/deepdb/retention.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down

0 comments on commit 85b6811

Please sign in to comment.