forked from TrueCloudLab/frostfs-node
[#1956] node: Lock shard's mode on its methods switch
Signed-off-by: Pavel Karpy <p.karpy@yadro.com>
This commit is contained in:
parent
33d279a3f2
commit
eea2892109
13 changed files with 94 additions and 22 deletions
|
@ -61,10 +61,13 @@ var ErrLockObjectRemoval = meta.ErrLockObjectRemoval
|
|||
//
|
||||
// Returns ErrReadOnlyMode error if shard is in "read-only" mode.
|
||||
func (s *Shard) Inhume(prm InhumePrm) (InhumeRes, error) {
|
||||
m := s.GetMode()
|
||||
if m.ReadOnly() {
|
||||
s.m.RLock()
|
||||
|
||||
if s.info.Mode.ReadOnly() {
|
||||
s.m.RUnlock()
|
||||
return InhumeRes{}, ErrReadOnlyMode
|
||||
} else if m.NoMetabase() {
|
||||
} else if s.info.Mode.NoMetabase() {
|
||||
s.m.RUnlock()
|
||||
return InhumeRes{}, ErrDegradedMode
|
||||
}
|
||||
|
||||
|
@ -91,6 +94,7 @@ func (s *Shard) Inhume(prm InhumePrm) (InhumeRes, error) {
|
|||
res, err := s.metaBase.Inhume(metaPrm)
|
||||
if err != nil {
|
||||
if errors.Is(err, meta.ErrLockObjectRemoval) {
|
||||
s.m.RUnlock()
|
||||
return InhumeRes{}, ErrLockObjectRemoval
|
||||
}
|
||||
|
||||
|
@ -98,9 +102,13 @@ func (s *Shard) Inhume(prm InhumePrm) (InhumeRes, error) {
|
|||
zap.String("error", err.Error()),
|
||||
)
|
||||
|
||||
s.m.RUnlock()
|
||||
|
||||
return InhumeRes{}, fmt.Errorf("metabase inhume: %w", err)
|
||||
}
|
||||
|
||||
s.m.RUnlock()
|
||||
|
||||
s.decObjectCounterBy(logical, res.AvailableInhumed())
|
||||
|
||||
if deletedLockObjs := res.DeletedLockObjects(); len(deletedLockObjs) != 0 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue