From d136ac05968286e9708ac874949f65663071cdaf Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Wed, 15 Feb 2023 22:09:25 -0800 Subject: [PATCH] Don't close transition task channel on server exit (#16627) --- cmd/bucket-lifecycle.go | 16 ++++++---------- cmd/erasure-object.go | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/cmd/bucket-lifecycle.go b/cmd/bucket-lifecycle.go index 32e9c6060..17140f5a9 100644 --- a/cmd/bucket-lifecycle.go +++ b/cmd/bucket-lifecycle.go @@ -152,7 +152,6 @@ type transitionTask struct { } type transitionState struct { - once sync.Once transitionCh chan transitionTask ctx context.Context @@ -169,10 +168,7 @@ type transitionState struct { func (t *transitionState) queueTransitionTask(oi ObjectInfo, sc string) { select { - case <-GlobalContext.Done(): - t.once.Do(func() { - close(t.transitionCh) - }) + case <-t.ctx.Done(): case t.transitionCh <- transitionTask{objInfo: oi, tier: sc}: default: } @@ -214,20 +210,20 @@ func (t *transitionState) ActiveTasks() int { } // worker waits for transition tasks -func (t *transitionState) worker(ctx context.Context, objectAPI ObjectLayer) { +func (t *transitionState) worker(objectAPI ObjectLayer) { for { select { case <-t.killCh: return - case <-ctx.Done(): + case <-t.ctx.Done(): return case task, ok := <-t.transitionCh: if !ok { return } atomic.AddInt32(&t.activeTasks, 1) - if err := transitionObject(ctx, objectAPI, task.objInfo, task.tier); err != nil { - logger.LogIf(ctx, fmt.Errorf("Transition failed for %s/%s version:%s with %w", + if err := transitionObject(t.ctx, objectAPI, task.objInfo, task.tier); err != nil { + logger.LogIf(t.ctx, fmt.Errorf("Transition failed for %s/%s version:%s with %w", task.objInfo.Bucket, task.objInfo.Name, task.objInfo.VersionID, err)) } else { ts := tierStats{ @@ -278,7 +274,7 @@ func (t *transitionState) UpdateWorkers(n int) { func (t *transitionState) updateWorkers(n int) { for t.numWorkers < n { - go t.worker(t.ctx, t.objAPI) + go t.worker(t.objAPI) t.numWorkers++ } diff --git a/cmd/erasure-object.go b/cmd/erasure-object.go index a4614a53b..d71f6e2fd 100644 --- a/cmd/erasure-object.go +++ b/cmd/erasure-object.go @@ -483,7 +483,7 @@ func (er erasureObjects) deleteIfDangling(ctx context.Context, bucket, object st if opts.VersionID != "" { fi.VersionID = opts.VersionID } - + fi.SetTierFreeVersionID(mustGetUUID()) disks := er.getDisks() g := errgroup.WithNErrs(len(disks)) for index := range disks {