[#1333] local_object_storage: Support ReadOnly mode in pilorama
The tricky part here is the engine itself: we stop iteration on `ErrReadOnly` because it is better to synchronize the shard later than to have partial trees stored in 2 shards. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
735931c842
commit
8f4ee1aded
2 changed files with 21 additions and 0 deletions
|
@ -1,7 +1,10 @@
|
||||||
package engine
|
package engine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/pilorama"
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/pilorama"
|
||||||
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
|
||||||
cidSDK "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
cidSDK "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
@ -19,6 +22,9 @@ func (e *StorageEngine) TreeMove(d pilorama.CIDDescriptor, treeID string, m *pil
|
||||||
zap.Stringer("cid", d.CID),
|
zap.Stringer("cid", d.CID),
|
||||||
zap.String("tree", treeID),
|
zap.String("tree", treeID),
|
||||||
zap.String("err", err.Error()))
|
zap.String("err", err.Error()))
|
||||||
|
if errors.Is(err, shard.ErrReadOnlyMode) {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return lm, nil
|
return lm, nil
|
||||||
|
@ -37,6 +43,9 @@ func (e *StorageEngine) TreeAddByPath(d pilorama.CIDDescriptor, treeID string, a
|
||||||
zap.Stringer("cid", d.CID),
|
zap.Stringer("cid", d.CID),
|
||||||
zap.String("tree", treeID),
|
zap.String("tree", treeID),
|
||||||
zap.String("err", err.Error()))
|
zap.String("err", err.Error()))
|
||||||
|
if errors.Is(err, shard.ErrReadOnlyMode) {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return lm, nil
|
return lm, nil
|
||||||
|
@ -54,6 +63,9 @@ func (e *StorageEngine) TreeApply(d pilorama.CIDDescriptor, treeID string, m *pi
|
||||||
zap.Stringer("cid", d.CID),
|
zap.Stringer("cid", d.CID),
|
||||||
zap.String("tree", treeID),
|
zap.String("tree", treeID),
|
||||||
zap.String("err", err.Error()))
|
zap.String("err", err.Error()))
|
||||||
|
if errors.Is(err, shard.ErrReadOnlyMode) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -9,16 +9,25 @@ var _ pilorama.Forest = (*Shard)(nil)
|
||||||
|
|
||||||
// TreeMove implements the pilorama.Forest interface.
|
// TreeMove implements the pilorama.Forest interface.
|
||||||
func (s *Shard) TreeMove(d pilorama.CIDDescriptor, treeID string, m *pilorama.Move) (*pilorama.LogMove, error) {
|
func (s *Shard) TreeMove(d pilorama.CIDDescriptor, treeID string, m *pilorama.Move) (*pilorama.LogMove, error) {
|
||||||
|
if s.GetMode() != ModeReadWrite {
|
||||||
|
return nil, ErrReadOnlyMode
|
||||||
|
}
|
||||||
return s.pilorama.TreeMove(d, treeID, m)
|
return s.pilorama.TreeMove(d, treeID, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TreeAddByPath implements the pilorama.Forest interface.
|
// TreeAddByPath implements the pilorama.Forest interface.
|
||||||
func (s *Shard) TreeAddByPath(d pilorama.CIDDescriptor, treeID string, attr string, path []string, meta []pilorama.KeyValue) ([]pilorama.LogMove, error) {
|
func (s *Shard) TreeAddByPath(d pilorama.CIDDescriptor, treeID string, attr string, path []string, meta []pilorama.KeyValue) ([]pilorama.LogMove, error) {
|
||||||
|
if s.GetMode() != ModeReadWrite {
|
||||||
|
return nil, ErrReadOnlyMode
|
||||||
|
}
|
||||||
return s.pilorama.TreeAddByPath(d, treeID, attr, path, meta)
|
return s.pilorama.TreeAddByPath(d, treeID, attr, path, meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TreeApply implements the pilorama.Forest interface.
|
// TreeApply implements the pilorama.Forest interface.
|
||||||
func (s *Shard) TreeApply(d pilorama.CIDDescriptor, treeID string, m *pilorama.Move) error {
|
func (s *Shard) TreeApply(d pilorama.CIDDescriptor, treeID string, m *pilorama.Move) error {
|
||||||
|
if s.GetMode() != ModeReadWrite {
|
||||||
|
return ErrReadOnlyMode
|
||||||
|
}
|
||||||
return s.pilorama.TreeApply(d, treeID, m)
|
return s.pilorama.TreeApply(d, treeID, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue