[#1957] engine: Move shard to read-only if cannot move to degraded

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
Evgenii Stratonikov 2022-10-24 11:31:56 +03:00 committed by fyrchik
parent 7f54462e60
commit 3b939d190c

View file

@ -40,9 +40,10 @@ func (e *StorageEngine) reportShardError(
msg string,
err error,
fields ...zap.Field) {
sid := sh.ID()
errCount := sh.errorCount.Inc()
e.log.Warn(msg, append([]zap.Field{
zap.Stringer("shard_id", sh.ID()),
zap.Stringer("shard_id", sid),
zap.Uint32("error count", errCount),
zap.String("error", err.Error()),
}, fields...)...)
@ -53,12 +54,25 @@ func (e *StorageEngine) reportShardError(
err = sh.SetMode(mode.DegradedReadOnly)
if err != nil {
e.log.Error("failed to move shard in degraded mode",
e.log.Error("failed to move shard in degraded-read-only mode, moving to read-only",
zap.Stringer("shard_id", sid),
zap.Uint32("error count", errCount),
zap.Error(err))
err = sh.SetMode(mode.ReadOnly)
if err != nil {
e.log.Error("failed to move shard in read-only mode",
zap.Stringer("shard_id", sid),
zap.Uint32("error count", errCount),
zap.Error(err))
} else {
e.log.Info("shard is moved in read-only mode due to error threshold",
zap.Stringer("shard_id", sid),
zap.Uint32("error count", errCount))
}
} else {
e.log.Info("shard is moved in degraded mode due to error threshold",
zap.Stringer("shard_id", sh.ID()),
zap.Stringer("shard_id", sid),
zap.Uint32("error count", errCount))
}
}