[#1413] engine: Cleanup shard error reporting
- `reportShardErrorBackground()` no longer differs from `reportShardError()`, reflect this in its name; - reuse common pieces of code to make it simpler. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
9a87acb87a
commit
963faa615a
2 changed files with 5 additions and 25 deletions
|
@ -115,10 +115,8 @@ func (e *StorageEngine) moveToDegraded(sh *shard.Shard, errCount uint32, isMeta
|
|||
log.Info(logs.EngineShardIsMovedInReadonlyModeDueToErrorThreshold)
|
||||
}
|
||||
|
||||
// reportShardErrorBackground increases shard error counter and logs an error.
|
||||
// It is intended to be used from background workers and
|
||||
// doesn't change shard mode because of possible deadlocks.
|
||||
func (e *StorageEngine) reportShardErrorBackground(id string, msg string, err error) {
|
||||
// reportShardErrorByID increases shard error counter and logs an error.
|
||||
func (e *StorageEngine) reportShardErrorByID(id string, msg string, err error) {
|
||||
e.mtx.RLock()
|
||||
sh, ok := e.shards[id]
|
||||
e.mtx.RUnlock()
|
||||
|
@ -127,16 +125,7 @@ func (e *StorageEngine) reportShardErrorBackground(id string, msg string, err er
|
|||
return
|
||||
}
|
||||
|
||||
if isLogical(err) {
|
||||
e.log.Warn(msg,
|
||||
zap.Stringer("shard_id", sh.ID()),
|
||||
zap.String("error", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
errCount := sh.errorCount.Add(1)
|
||||
sh.Shard.IncErrorCounter()
|
||||
e.reportShardErrorWithFlags(sh.Shard, errCount, msg, err)
|
||||
e.reportShardError(sh, msg, err)
|
||||
}
|
||||
|
||||
// reportShardError checks that the amount of errors doesn't exceed the configured threshold.
|
||||
|
@ -156,16 +145,7 @@ func (e *StorageEngine) reportShardError(
|
|||
|
||||
errCount := sh.errorCount.Add(1)
|
||||
sh.Shard.IncErrorCounter()
|
||||
e.reportShardErrorWithFlags(sh.Shard, errCount, msg, err, fields...)
|
||||
}
|
||||
|
||||
func (e *StorageEngine) reportShardErrorWithFlags(
|
||||
sh *shard.Shard,
|
||||
errCount uint32,
|
||||
msg string,
|
||||
err error,
|
||||
fields ...zap.Field,
|
||||
) {
|
||||
sid := sh.ID()
|
||||
e.log.Warn(msg, append([]zap.Field{
|
||||
zap.Stringer("shard_id", sid),
|
||||
|
@ -179,7 +159,7 @@ func (e *StorageEngine) reportShardErrorWithFlags(
|
|||
|
||||
req := setModeRequest{
|
||||
errorCount: errCount,
|
||||
sh: sh,
|
||||
sh: sh.Shard,
|
||||
isMeta: errors.As(err, new(metaerr.Error)),
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ func (e *StorageEngine) createShard(_ context.Context, opts []shard.Option) (*sh
|
|||
shard.WithExpiredTombstonesCallback(e.processExpiredTombstones),
|
||||
shard.WithExpiredLocksCallback(e.processExpiredLocks),
|
||||
shard.WithDeletedLockCallback(e.processDeletedLocks),
|
||||
shard.WithReportErrorFunc(e.reportShardErrorBackground),
|
||||
shard.WithReportErrorFunc(e.reportShardErrorByID),
|
||||
shard.WithZeroSizeCallback(e.processZeroSizeContainers),
|
||||
shard.WithZeroCountCallback(e.processZeroCountContainers),
|
||||
)...)
|
||||
|
|
Loading…
Reference in a new issue