Compare commits
1 commit
master
...
fix-writec
Author | SHA1 | Date | |
---|---|---|---|
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
|
||||
}
|
||||
defer c.modeMtx.RUnlock()
|
||||
if c.mode.NoMetabase() {
|
||||
return ErrDegraded
|
||||
}
|
||||
if c.readOnly() {
|
||||
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)
|
||||
}()
|
||||
|
||||
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))
|
||||
if err == nil {
|
||||
obj := objectSDK.New()
|
||||
|
|
|
@ -38,6 +38,9 @@ func (c *cache) Put(ctx context.Context, prm common.PutPrm) (common.PutRes, erro
|
|||
return common.PutRes{}, ErrNotInitialized
|
||||
}
|
||||
defer c.modeMtx.RUnlock()
|
||||
if c.mode.NoMetabase() {
|
||||
return common.PutRes{}, ErrDegraded
|
||||
}
|
||||
if c.readOnly() {
|
||||
return common.PutRes{}, ErrReadOnly
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@ func (c *cache) Seal(ctx context.Context, ignoreErrors bool) error {
|
|||
|
||||
c.modeMtx.Lock()
|
||||
defer c.modeMtx.Unlock()
|
||||
if c.mode.NoMetabase() {
|
||||
return ErrDegraded
|
||||
}
|
||||
|
||||
// flush will be done by setMode
|
||||
err := c.setMode(ctx, mode.DegradedReadOnly, ignoreErrors)
|
||||
|
|
|
@ -65,4 +65,6 @@ var (
|
|||
ErrBigObject = errors.New("too big 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")
|
||||
// ErrDegraded is returned when writecache is in degraded mode.
|
||||
ErrDegraded = logicerr.New("write-cache is in degraded mode")
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue