forked from TrueCloudLab/frostfs-node
writecache: Check whether we are in a degraded mode
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
5cbf57081f
commit
a550fb584b
5 changed files with 19 additions and 0 deletions
|
@ -37,6 +37,9 @@ func (c *cache) Delete(ctx context.Context, addr oid.Address) error {
|
||||||
return ErrNotInitialized
|
return ErrNotInitialized
|
||||||
}
|
}
|
||||||
defer c.modeMtx.RUnlock()
|
defer c.modeMtx.RUnlock()
|
||||||
|
if c.mode.NoMetabase() {
|
||||||
|
return ErrDegraded
|
||||||
|
}
|
||||||
if c.readOnly() {
|
if c.readOnly() {
|
||||||
return ErrReadOnly
|
return ErrReadOnly
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,14 @@ func (c *cache) getInternal(ctx context.Context, saddr string, addr oid.Address)
|
||||||
c.metrics.Get(time.Since(startedAt), found, storageType)
|
c.metrics.Get(time.Since(startedAt), found, storageType)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
if !c.modeMtx.TryRLock() {
|
||||||
|
return nil, ErrNotInitialized
|
||||||
|
}
|
||||||
|
defer c.modeMtx.RUnlock()
|
||||||
|
if c.mode.NoMetabase() {
|
||||||
|
return nil, ErrDegraded
|
||||||
|
}
|
||||||
|
|
||||||
value, err := Get(c.db, []byte(saddr))
|
value, err := Get(c.db, []byte(saddr))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
obj := objectSDK.New()
|
obj := objectSDK.New()
|
||||||
|
|
|
@ -38,6 +38,9 @@ func (c *cache) Put(ctx context.Context, prm common.PutPrm) (common.PutRes, erro
|
||||||
return common.PutRes{}, ErrNotInitialized
|
return common.PutRes{}, ErrNotInitialized
|
||||||
}
|
}
|
||||||
defer c.modeMtx.RUnlock()
|
defer c.modeMtx.RUnlock()
|
||||||
|
if c.mode.NoMetabase() {
|
||||||
|
return common.PutRes{}, ErrDegraded
|
||||||
|
}
|
||||||
if c.readOnly() {
|
if c.readOnly() {
|
||||||
return common.PutRes{}, ErrReadOnly
|
return common.PutRes{}, ErrReadOnly
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,9 @@ func (c *cache) Seal(ctx context.Context, ignoreErrors bool) error {
|
||||||
|
|
||||||
c.modeMtx.Lock()
|
c.modeMtx.Lock()
|
||||||
defer c.modeMtx.Unlock()
|
defer c.modeMtx.Unlock()
|
||||||
|
if c.mode.NoMetabase() {
|
||||||
|
return ErrDegraded
|
||||||
|
}
|
||||||
|
|
||||||
// flush will be done by setMode
|
// flush will be done by setMode
|
||||||
err := c.setMode(ctx, mode.DegradedReadOnly, ignoreErrors)
|
err := c.setMode(ctx, mode.DegradedReadOnly, ignoreErrors)
|
||||||
|
|
|
@ -65,4 +65,6 @@ var (
|
||||||
ErrBigObject = errors.New("too big object")
|
ErrBigObject = errors.New("too big object")
|
||||||
// ErrOutOfSpace is returned when there is no space left to put a new object.
|
// ErrOutOfSpace is returned when there is no space left to put a new object.
|
||||||
ErrOutOfSpace = errors.New("no space left in the write cache")
|
ErrOutOfSpace = errors.New("no space left in the write cache")
|
||||||
|
// ErrDegraded is returned when writecache is in degraded mode.
|
||||||
|
ErrDegraded = logicerr.New("write-cache is in degraded mode")
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue