[#959] writecache: Avoid manipulation with cache in DEGRADED mode

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
Anton Nikiforov 2024-02-20 17:24:57 +03:00 committed by Evgenii Stratonikov
parent d433b49265
commit 3195142d67
6 changed files with 35 additions and 1 deletions

View file

@ -155,7 +155,7 @@ func (c *cache) workerFlushBig(ctx context.Context) {
select {
case <-tick.C:
c.modeMtx.RLock()
if c.readOnly() {
if c.readOnly() || c.noMetabase() {
c.modeMtx.RUnlock()
break
}
@ -281,6 +281,9 @@ func (c *cache) Flush(ctx context.Context, ignoreErrors, seal bool) error {
c.modeMtx.Lock() // exclusive lock to not to conflict with background flush
defer c.modeMtx.Unlock()
if c.noMetabase() {
return ErrDegraded
}
if err := c.flush(ctx, ignoreErrors); err != nil {
return err