[#1071] Revert "[#446] engine: Move to read-only on blobstor errors"
DCO action / DCO (pull_request) Successful in 3m47s Details
Vulncheck / Vulncheck (pull_request) Failing after 3m56s Details
Build / Build Components (1.21) (pull_request) Successful in 5m10s Details
Build / Build Components (1.20) (pull_request) Successful in 6m4s Details
Tests and linters / Staticcheck (pull_request) Successful in 5m42s Details
Tests and linters / Tests with -race (pull_request) Failing after 12m32s Details
Tests and linters / Tests (1.21) (pull_request) Successful in 13m37s Details
Tests and linters / Lint (pull_request) Successful in 11m34s Details
Tests and linters / Tests (1.20) (pull_request) Successful in 3m2s Details

This reverts commit 69df0d21c2.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
pull/1071/head
Evgenii Stratonikov 2024-03-28 11:08:20 +03:00
parent 2bfaa65455
commit bb6d8d0c0d
2 changed files with 15 additions and 21 deletions

View File

@ -7,7 +7,6 @@ import (
"sync/atomic"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/metaerr"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr"
@ -48,7 +47,6 @@ type shardWrapper struct {
type setModeRequest struct {
sh *shard.Shard
isMeta bool
errorCount uint32
}
@ -74,7 +72,7 @@ func (e *StorageEngine) setModeLoop() {
if !ok {
inProgress[sid] = struct{}{}
go func() {
e.moveToDegraded(r.sh, r.errorCount, r.isMeta)
e.moveToDegraded(r.sh, r.errorCount)
mtx.Lock()
delete(inProgress, sid)
@ -86,7 +84,7 @@ func (e *StorageEngine) setModeLoop() {
}
}
func (e *StorageEngine) moveToDegraded(sh *shard.Shard, errCount uint32, isMeta bool) {
func (e *StorageEngine) moveToDegraded(sh *shard.Shard, errCount uint32) {
sid := sh.ID()
log := e.log.With(
zap.Stringer("shard_id", sid),
@ -95,23 +93,21 @@ func (e *StorageEngine) moveToDegraded(sh *shard.Shard, errCount uint32, isMeta
e.mtx.RLock()
defer e.mtx.RUnlock()
if isMeta {
err := sh.SetMode(mode.DegradedReadOnly)
if err == nil {
log.Info(logs.EngineShardIsMovedInDegradedModeDueToErrorThreshold)
return
}
err := sh.SetMode(mode.DegradedReadOnly)
if err != nil {
log.Error(logs.EngineFailedToMoveShardInDegradedreadonlyModeMovingToReadonly,
zap.Error(err))
}
err := sh.SetMode(mode.ReadOnly)
if err != nil {
log.Error(logs.EngineFailedToMoveShardInReadonlyMode, zap.Error(err))
return
err = sh.SetMode(mode.ReadOnly)
if err != nil {
log.Error(logs.EngineFailedToMoveShardInReadonlyMode,
zap.Error(err))
} else {
log.Info(logs.EngineShardIsMovedInReadonlyModeDueToErrorThreshold)
}
} else {
log.Info(logs.EngineShardIsMovedInDegradedModeDueToErrorThreshold)
}
log.Info(logs.EngineShardIsMovedInReadonlyModeDueToErrorThreshold)
}
// reportShardErrorBackground increases shard error counter and logs an error.
@ -175,13 +171,11 @@ func (e *StorageEngine) reportShardErrorWithFlags(
return
}
isMeta := errors.As(err, new(metaerr.Error))
if block {
e.moveToDegraded(sh, errCount, isMeta)
e.moveToDegraded(sh, errCount)
} else {
req := setModeRequest{
errorCount: errCount,
isMeta: isMeta,
sh: sh,
}

View File

@ -152,7 +152,7 @@ func TestErrorReporting(t *testing.T) {
for i := uint32(0); i < 2; i++ {
_, err = te.ng.Get(context.Background(), GetPrm{addr: object.AddressOf(obj)})
require.Error(t, err)
checkShardState(t, te.ng, te.shards[0].id, errThreshold+i, mode.ReadOnly)
checkShardState(t, te.ng, te.shards[0].id, errThreshold+i, mode.DegradedReadOnly)
checkShardState(t, te.ng, te.shards[1].id, 0, mode.ReadWrite)
}