[#1086] engine: Do not use metabase if shard looks bad
All checks were successful
DCO action / DCO (pull_request) Successful in 9m41s
Vulncheck / Vulncheck (pull_request) Successful in 12m0s
Build / Build Components (1.22) (pull_request) Successful in 15m39s
Build / Build Components (1.21) (pull_request) Successful in 15m44s
Pre-commit hooks / Pre-commit (pull_request) Successful in 26m49s
Tests and linters / Staticcheck (pull_request) Successful in 5m16s
Tests and linters / gopls check (pull_request) Successful in 5m15s
Tests and linters / Lint (pull_request) Successful in 5m58s
Tests and linters / Tests with -race (pull_request) Successful in 8m32s
Tests and linters / Tests (1.21) (pull_request) Successful in 8m56s
Tests and linters / Tests (1.22) (pull_request) Successful in 9m0s

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2024-04-17 14:15:08 +03:00 committed by Evgenii Stratonikov
parent 67a1355c47
commit 32da6a7606
2 changed files with 6 additions and 3 deletions

View file

@ -84,6 +84,7 @@ func (e *StorageEngine) head(ctx context.Context, prm HeadPrm) (HeadRes, error)
shPrm.SetRaw(prm.raw)
e.iterateOverSortedShards(prm.addr, func(_ int, sh hashedShard) (stop bool) {
shPrm.ShardLooksBad = sh.errorCount.Load() >= e.errorsThreshold
res, err := sh.Head(ctx, shPrm)
if err != nil {
switch {

View file

@ -15,6 +15,7 @@ import (
type HeadPrm struct {
addr oid.Address
raw bool
ShardLooksBad bool
}
// HeadRes groups the resulting values of Head operation.
@ -59,7 +60,8 @@ func (s *Shard) Head(ctx context.Context, prm HeadPrm) (HeadRes, error) {
var obj *objectSDK.Object
var err error
if s.GetMode().NoMetabase() {
mode := s.GetMode()
if mode.NoMetabase() || (mode.ReadOnly() && prm.ShardLooksBad) {
var getPrm GetPrm
getPrm.SetAddress(prm.addr)
getPrm.SetIgnoreMeta(true)