[#1869] shard: Add logs for SetMode operations on reload

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
Evgenii Stratonikov 2022-10-16 16:19:14 +03:00 committed by fyrchik
parent 87be4f1629
commit 1beafea0b5

View file

@ -282,6 +282,7 @@ func (s *Shard) Reload(opts ...Option) error {
ok, err := s.metaBase.Reload(c.metaOpts...)
if err != nil {
if errors.Is(err, meta.ErrDegradedMode) {
s.log.Error("can't open metabase, move to a degraded mode", zap.Error(err))
_ = s.setMode(mode.DegradedReadOnly)
}
return err
@ -297,10 +298,12 @@ func (s *Shard) Reload(opts ...Option) error {
err = s.metaBase.Init()
}
if err != nil {
s.log.Error("can't initialize metabase, move to a degraded-read-only mode", zap.Error(err))
_ = s.setMode(mode.DegradedReadOnly)
return err
}
}
s.log.Info("trying to restore read-write mode")
return s.setMode(mode.ReadWrite)
}