forked from TrueCloudLab/frostfs-node
[#745] gc: Stop GC work on Shard
's Close
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
6527f9157c
commit
3d981320c6
3 changed files with 23 additions and 7 deletions
|
@ -39,9 +39,10 @@ func (s *Shard) Init() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gc := &gc{
|
s.gc = &gc{
|
||||||
gcCfg: s.gcCfg,
|
gcCfg: s.gcCfg,
|
||||||
remover: s.removeGarbage,
|
remover: s.removeGarbage,
|
||||||
|
stopChannel: make(chan struct{}),
|
||||||
mEventHandler: map[eventType]*eventHandlers{
|
mEventHandler: map[eventType]*eventHandlers{
|
||||||
eventNewEpoch: {
|
eventNewEpoch: {
|
||||||
cancelFunc: func() {},
|
cancelFunc: func() {},
|
||||||
|
@ -53,7 +54,7 @@ func (s *Shard) Init() error {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
gc.init()
|
s.gc.init()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -74,5 +75,7 @@ func (s *Shard) Close() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.gc.stop()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,8 @@ type eventHandlers struct {
|
||||||
type gc struct {
|
type gc struct {
|
||||||
*gcCfg
|
*gcCfg
|
||||||
|
|
||||||
|
stopChannel chan struct{}
|
||||||
|
|
||||||
workerPool util.WorkerPool
|
workerPool util.WorkerPool
|
||||||
|
|
||||||
remover func()
|
remover func()
|
||||||
|
@ -146,12 +148,21 @@ func (gc *gc) tickRemover() {
|
||||||
defer timer.Stop()
|
defer timer.Stop()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
<-timer.C
|
select {
|
||||||
gc.remover()
|
case <-gc.stopChannel:
|
||||||
timer.Reset(gc.removerInterval)
|
gc.log.Debug("GC is stopped")
|
||||||
|
return
|
||||||
|
case <-timer.C:
|
||||||
|
gc.remover()
|
||||||
|
timer.Reset(gc.removerInterval)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gc *gc) stop() {
|
||||||
|
gc.stopChannel <- struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
// iterates over metabase graveyard and deletes objects
|
// iterates over metabase graveyard and deletes objects
|
||||||
// with GC-marked graves.
|
// with GC-marked graves.
|
||||||
func (s *Shard) removeGarbage() {
|
func (s *Shard) removeGarbage() {
|
||||||
|
|
|
@ -18,6 +18,8 @@ import (
|
||||||
type Shard struct {
|
type Shard struct {
|
||||||
*cfg
|
*cfg
|
||||||
|
|
||||||
|
gc *gc
|
||||||
|
|
||||||
mode *atomic.Uint32
|
mode *atomic.Uint32
|
||||||
|
|
||||||
writeCache writecache.Cache
|
writeCache writecache.Cache
|
||||||
|
|
Loading…
Reference in a new issue