[#1907] shard: Return from `Close` after GC has stopped

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
support/v0.34
Evgenii Stratonikov 2022-10-25 09:08:18 +03:00 committed by fyrchik
parent 4fe1aad30f
commit 713fdab177
2 changed files with 10 additions and 0 deletions

View File

@ -24,6 +24,7 @@ Changelog for NeoFS Node
- Correctly sign new epoch transaction in neofs-adm for a committee of more than 4 nodes (#1949)
- Inability to provide session to NeoFS CLI in a NeoFS-binary format (#1933)
- `neofs-adm` now works correctly with a committee of more than 4 nodes (#1949, #1959)
- Closing a shard now waits until GC background workers stop (#1964)
### Removed
### Updated

View File

@ -65,6 +65,7 @@ type gc struct {
onceStop sync.Once
stopChannel chan struct{}
wg sync.WaitGroup
workerPool util.WorkerPool
@ -103,11 +104,14 @@ func (gc *gc) init() {
gc.workerPool = gc.workerPoolInit(sz)
}
gc.wg.Add(2)
go gc.tickRemover()
go gc.listenEvents()
}
func (gc *gc) listenEvents() {
defer gc.wg.Done()
for {
event, ok := <-gc.eventChan
if !ok {
@ -147,6 +151,8 @@ func (gc *gc) listenEvents() {
}
func (gc *gc) tickRemover() {
defer gc.wg.Done()
timer := time.NewTimer(gc.removerInterval)
defer timer.Stop()
@ -172,6 +178,9 @@ func (gc *gc) stop() {
gc.onceStop.Do(func() {
gc.stopChannel <- struct{}{}
})
gc.log.Info("waiting for GC workers to stop...")
gc.wg.Wait()
}
// iterates over metabase and deletes objects