Reapply "[#446] engine: Move to read-only on blobstor errors"
All checks were successful
DCO action / DCO (pull_request) Successful in 3m39s
Vulncheck / Vulncheck (pull_request) Successful in 4m6s
Build / Build Components (1.21) (pull_request) Successful in 4m34s
Build / Build Components (1.20) (pull_request) Successful in 4m45s
Tests and linters / gopls check (pull_request) Successful in 5m7s
Tests and linters / Staticcheck (pull_request) Successful in 6m5s
Tests and linters / Lint (pull_request) Successful in 7m6s
Tests and linters / Tests (1.20) (pull_request) Successful in 9m0s
Tests and linters / Tests (1.21) (pull_request) Successful in 9m25s
Tests and linters / Tests with -race (pull_request) Successful in 9m46s
All checks were successful
DCO action / DCO (pull_request) Successful in 3m39s
Vulncheck / Vulncheck (pull_request) Successful in 4m6s
Build / Build Components (1.21) (pull_request) Successful in 4m34s
Build / Build Components (1.20) (pull_request) Successful in 4m45s
Tests and linters / gopls check (pull_request) Successful in 5m7s
Tests and linters / Staticcheck (pull_request) Successful in 6m5s
Tests and linters / Lint (pull_request) Successful in 7m6s
Tests and linters / Tests (1.20) (pull_request) Successful in 9m0s
Tests and linters / Tests (1.21) (pull_request) Successful in 9m25s
Tests and linters / Tests with -race (pull_request) Successful in 9m46s
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
67a6da470f
commit
ba374c7907
2 changed files with 20 additions and 15 deletions
|
@ -8,6 +8,7 @@ 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"
|
||||
|
@ -49,6 +50,7 @@ type shardWrapper struct {
|
|||
|
||||
type setModeRequest struct {
|
||||
sh *shard.Shard
|
||||
isMeta bool
|
||||
errorCount uint32
|
||||
}
|
||||
|
||||
|
@ -74,7 +76,7 @@ func (e *StorageEngine) setModeLoop() {
|
|||
if !ok {
|
||||
inProgress[sid] = struct{}{}
|
||||
go func() {
|
||||
e.moveToDegraded(r.sh, r.errorCount)
|
||||
e.moveToDegraded(r.sh, r.errorCount, r.isMeta)
|
||||
|
||||
mtx.Lock()
|
||||
delete(inProgress, sid)
|
||||
|
@ -86,7 +88,7 @@ func (e *StorageEngine) setModeLoop() {
|
|||
}
|
||||
}
|
||||
|
||||
func (e *StorageEngine) moveToDegraded(sh *shard.Shard, errCount uint32) {
|
||||
func (e *StorageEngine) moveToDegraded(sh *shard.Shard, errCount uint32, isMeta bool) {
|
||||
sid := sh.ID()
|
||||
log := e.log.With(
|
||||
zap.Stringer("shard_id", sid),
|
||||
|
@ -95,21 +97,23 @@ func (e *StorageEngine) moveToDegraded(sh *shard.Shard, errCount uint32) {
|
|||
e.mtx.RLock()
|
||||
defer e.mtx.RUnlock()
|
||||
|
||||
err := sh.SetMode(mode.DegradedReadOnly)
|
||||
if err != nil {
|
||||
if isMeta {
|
||||
err := sh.SetMode(mode.DegradedReadOnly)
|
||||
if err == nil {
|
||||
log.Info(logs.EngineShardIsMovedInDegradedModeDueToErrorThreshold)
|
||||
return
|
||||
}
|
||||
log.Error(logs.EngineFailedToMoveShardInDegradedreadonlyModeMovingToReadonly,
|
||||
zap.Error(err))
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
err := sh.SetMode(mode.ReadOnly)
|
||||
if err != nil {
|
||||
log.Error(logs.EngineFailedToMoveShardInReadonlyMode, zap.Error(err))
|
||||
return
|
||||
}
|
||||
|
||||
log.Info(logs.EngineShardIsMovedInReadonlyModeDueToErrorThreshold)
|
||||
}
|
||||
|
||||
// reportShardErrorBackground increases shard error counter and logs an error.
|
||||
|
@ -177,6 +181,7 @@ func (e *StorageEngine) reportShardErrorWithFlags(
|
|||
req := setModeRequest{
|
||||
errorCount: errCount,
|
||||
sh: sh,
|
||||
isMeta: errors.As(err, new(metaerr.Error)),
|
||||
}
|
||||
|
||||
select {
|
||||
|
|
|
@ -154,7 +154,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.DegradedReadOnly)
|
||||
checkShardState(t, te.ng, te.shards[0].id, errThreshold+i, mode.ReadOnly)
|
||||
checkShardState(t, te.ng, te.shards[1].id, 0, mode.ReadWrite)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue