[#1284] writecache: Allow to seal writecache async

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2024-07-31 16:30:07 +03:00
parent 68029d756e
commit 93d63e1632
10 changed files with 252 additions and 170 deletions

View file

@ -178,6 +178,7 @@ func (s *Shard) Init(ctx context.Context) error {
if !m.NoMetabase() {
s.rb.Start(ctx, s.blobStor, s.metaBase, s.log)
}
s.writecacheSealCancel.Store(dummyCancel)
return nil
}
@ -350,6 +351,8 @@ func (s *Shard) Close() error {
}
if s.hasWriteCache() {
prev := s.writecacheSealCancel.Swap(notInitializedCancel)
prev.cancel() // no need to wait: writecache.Seal and writecache.Close lock the same mutex
components = append(components, s.writeCache)
}
@ -428,6 +431,9 @@ func (s *Shard) lockExclusive() func() {
cancelGC := val.(context.CancelFunc)
cancelGC()
}
if c := s.writecacheSealCancel.Load(); c != nil {
c.cancel()
}
s.m.Lock()
s.setModeRequested.Store(false)
return s.m.Unlock