From f23e38c28569716e2a770ca5f84df723449d597c Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 1 Apr 2024 12:48:30 +0300 Subject: [PATCH] Revert "[#446] engine: Move to read-only on blobstor errors" This reverts commit 69df0d21c2d5f14a28d45951c32702ceec9da759. Signed-off-by: Evgenii Stratonikov --- pkg/local_object_storage/engine/engine.go | 34 ++++++++----------- pkg/local_object_storage/engine/error_test.go | 2 +- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/pkg/local_object_storage/engine/engine.go b/pkg/local_object_storage/engine/engine.go index e03a08abc..558fe92ed 100644 --- a/pkg/local_object_storage/engine/engine.go +++ b/pkg/local_object_storage/engine/engine.go @@ -8,7 +8,6 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/container" - "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" @@ -50,7 +49,6 @@ type shardWrapper struct { type setModeRequest struct { sh *shard.Shard - isMeta bool errorCount uint32 } @@ -76,7 +74,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) @@ -88,7 +86,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), @@ -97,23 +95,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. @@ -179,13 +175,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, } diff --git a/pkg/local_object_storage/engine/error_test.go b/pkg/local_object_storage/engine/error_test.go index 7f48da08a..ec4287bdd 100644 --- a/pkg/local_object_storage/engine/error_test.go +++ b/pkg/local_object_storage/engine/error_test.go @@ -153,7 +153,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) }