Skip to content

Commit

Permalink
init context in constructor
Browse files Browse the repository at this point in the history
Signed-off-by: Yi Jin <yi.jin@databricks.com>
  • Loading branch information
jnyi committed Apr 11, 2024
1 parent e21429d commit 923290d
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
- [#7224](https://github.com/thanos-io/thanos/pull/7224) Query-frontend: Add Redis username to the client configuration.
- [#7220](https://github.com/thanos-io/thanos/pull/7220) Store Gateway: Fix lazy expanded postings caching partial expanded postings and bug of estimating remove postings with non existent value. Added `PromQLSmith` based fuzz test to improve correctness.
- [#7244](https://github.com/thanos-io/thanos/pull/7244) Query: Fix Internal Server Error unknown targetHealth: "unknown" when trying to open the targets page.
- [#7248](https://github.com/thanos-io/thanos/pull/7248) Receive: Fix RemoteWriteAsync was sequentia lly executed causing high latency in the ingestion path.
- [#7248](https://github.com/thanos-io/thanos/pull/7248) Receive: Fix RemoteWriteAsync was sequentially executed causing high latency in the ingestion path.
- [#7271](https://github.com/thanos-io/thanos/pull/7271) Query: fixing dedup iterator when working on mixed sample types.

### Added
9 changes: 5 additions & 4 deletions pkg/pool/worker_pool.go
Original file line number Diff line number Diff line change
@@ -28,26 +28,27 @@ type WorkerPool interface {

type workerPool struct {
sync.Once
ctx context.Context
workCh chan Work
cancel context.CancelFunc
}

func NewWorkerPool(workers uint) WorkerPool {
ctx, cancel := context.WithCancel(context.Background())
return &workerPool{
ctx: ctx,
cancel: cancel,
workCh: make(chan Work, workers),
}
}

func (p *workerPool) Init() {
p.Do(func() {
ctx, cancel := context.WithCancel(context.Background())
p.cancel = cancel

for i := 0; i < p.Size(); i++ {
go func() {
for {
select {
case <-ctx.Done():
case <-p.ctx.Done():
// TODO: exhaust workCh before exit
return
case work := <-p.workCh:

0 comments on commit 923290d

Please sign in to comment.