forked from TrueCloudLab/frostfs-node
[#1906] writecache: Do not require read-only
mode in Flush
It was needed before we started to flush during transition to `degraded` mode. Now it is confusing. Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
parent
51a9306e41
commit
c38ad2d339
4 changed files with 2 additions and 13 deletions
|
@ -16,6 +16,7 @@ Changelog for NeoFS Node
|
||||||
- Increase error counter for write-cache flush errors (#1818)
|
- Increase error counter for write-cache flush errors (#1818)
|
||||||
- Broadcasting helper objects (#1972)
|
- Broadcasting helper objects (#1972)
|
||||||
- `neofs-cli lock object`'s `lifetime` flag handling (#1972)
|
- `neofs-cli lock object`'s `lifetime` flag handling (#1972)
|
||||||
|
- Do not move write-cache in read-only mode for flushing (#1906)
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
### Updated
|
### Updated
|
||||||
|
|
|
@ -2,8 +2,6 @@ package shard
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard/mode"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// FlushWriteCachePrm represents parameters of a `FlushWriteCache` operation.
|
// FlushWriteCachePrm represents parameters of a `FlushWriteCache` operation.
|
||||||
|
@ -20,8 +18,7 @@ func (p *FlushWriteCachePrm) SetIgnoreErrors(ignore bool) {
|
||||||
// but write-cache is disabled.
|
// but write-cache is disabled.
|
||||||
var errWriteCacheDisabled = errors.New("write-cache is disabled")
|
var errWriteCacheDisabled = errors.New("write-cache is disabled")
|
||||||
|
|
||||||
// FlushWriteCache moves writecache in read-only mode and flushes all data from it.
|
// FlushWriteCache flushes all data from the write-cache.
|
||||||
// After the operation writecache will remain read-only mode.
|
|
||||||
func (s *Shard) FlushWriteCache(p FlushWriteCachePrm) error {
|
func (s *Shard) FlushWriteCache(p FlushWriteCachePrm) error {
|
||||||
if !s.hasWriteCache() {
|
if !s.hasWriteCache() {
|
||||||
return errWriteCacheDisabled
|
return errWriteCacheDisabled
|
||||||
|
@ -38,9 +35,5 @@ func (s *Shard) FlushWriteCache(p FlushWriteCachePrm) error {
|
||||||
return ErrDegradedMode
|
return ErrDegradedMode
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.writeCache.SetMode(mode.ReadOnly); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.writeCache.Flush(p.ignoreErrors)
|
return s.writeCache.Flush(p.ignoreErrors)
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,10 +261,6 @@ func (c *cache) Flush(ignoreErrors bool) error {
|
||||||
c.modeMtx.RLock()
|
c.modeMtx.RLock()
|
||||||
defer c.modeMtx.RUnlock()
|
defer c.modeMtx.RUnlock()
|
||||||
|
|
||||||
if !c.mode.ReadOnly() {
|
|
||||||
return errMustBeReadOnly
|
|
||||||
}
|
|
||||||
|
|
||||||
return c.flush(ignoreErrors)
|
return c.flush(ignoreErrors)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,6 @@ func TestFlush(t *testing.T) {
|
||||||
wc, bs, mb := newCache(t)
|
wc, bs, mb := newCache(t)
|
||||||
objects := putObjects(t, wc)
|
objects := putObjects(t, wc)
|
||||||
|
|
||||||
require.NoError(t, wc.SetMode(mode.ReadOnly))
|
|
||||||
require.NoError(t, bs.SetMode(mode.ReadWrite))
|
require.NoError(t, bs.SetMode(mode.ReadWrite))
|
||||||
require.NoError(t, mb.SetMode(mode.ReadWrite))
|
require.NoError(t, mb.SetMode(mode.ReadWrite))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue