forked from TrueCloudLab/frostfs-node
[#176] shard: Get rid of using the global RW lock
In previous implementation each shard operation locked RW shard mutex. With this approach RW operations were executed one-by-one and blocked the execution of RO operations. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
9ab371aafb
commit
df558cbe6b
6 changed files with 0 additions and 20 deletions
|
@ -31,9 +31,6 @@ func (p *DeletePrm) WithAddress(addr *objectSDK.Address) *DeletePrm {
|
||||||
// Returns any error encountered that did not allow to completely
|
// Returns any error encountered that did not allow to completely
|
||||||
// mark the object to delete.
|
// mark the object to delete.
|
||||||
func (s *Shard) Delete(prm *DeletePrm) (*DeleteRes, error) {
|
func (s *Shard) Delete(prm *DeletePrm) (*DeleteRes, error) {
|
||||||
s.mtx.Lock()
|
|
||||||
defer s.mtx.Unlock()
|
|
||||||
|
|
||||||
// mark object to delete in metabase
|
// mark object to delete in metabase
|
||||||
if err := s.metaBase.Delete(prm.addr); err != nil {
|
if err := s.metaBase.Delete(prm.addr); err != nil {
|
||||||
s.log.Warn("could not mark object to delete in metabase",
|
s.log.Warn("could not mark object to delete in metabase",
|
||||||
|
|
|
@ -33,9 +33,6 @@ func (p *ExistsRes) Exists() bool {
|
||||||
// Returns any error encountered that does not allow to
|
// Returns any error encountered that does not allow to
|
||||||
// unambiguously determine the presence of an object.
|
// unambiguously determine the presence of an object.
|
||||||
func (s *Shard) Exists(prm *ExistsPrm) (*ExistsRes, error) {
|
func (s *Shard) Exists(prm *ExistsPrm) (*ExistsRes, error) {
|
||||||
s.mtx.RLock()
|
|
||||||
defer s.mtx.RUnlock()
|
|
||||||
|
|
||||||
// FIXME: implement me
|
// FIXME: implement me
|
||||||
return &ExistsRes{
|
return &ExistsRes{
|
||||||
ex: false,
|
ex: false,
|
||||||
|
|
|
@ -71,9 +71,6 @@ func (r *GetRes) Object() *object.Object {
|
||||||
//
|
//
|
||||||
// Returns ErrObjectNotFound if requested object is missing in shard.
|
// Returns ErrObjectNotFound if requested object is missing in shard.
|
||||||
func (s *Shard) Get(prm *GetPrm) (*GetRes, error) {
|
func (s *Shard) Get(prm *GetPrm) (*GetRes, error) {
|
||||||
s.mtx.RLock()
|
|
||||||
defer s.mtx.RUnlock()
|
|
||||||
|
|
||||||
if prm.ln < 0 {
|
if prm.ln < 0 {
|
||||||
// try to read from WriteCache
|
// try to read from WriteCache
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
|
|
|
@ -28,9 +28,6 @@ func (p *PutPrm) WithObject(obj *object.Object) *PutPrm {
|
||||||
// Returns any error encountered that
|
// Returns any error encountered that
|
||||||
// did not allow to completely save the object.
|
// did not allow to completely save the object.
|
||||||
func (s *Shard) Put(prm *PutPrm) (*PutRes, error) {
|
func (s *Shard) Put(prm *PutPrm) (*PutRes, error) {
|
||||||
s.mtx.Lock()
|
|
||||||
defer s.mtx.Unlock()
|
|
||||||
|
|
||||||
// check object existence
|
// check object existence
|
||||||
ex, err := s.metaBase.Exists(prm.obj.Address())
|
ex, err := s.metaBase.Exists(prm.obj.Address())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -34,9 +34,6 @@ func (r *SelectRes) AddressList() []*objectSDK.Address {
|
||||||
// Returns any error encountered that
|
// Returns any error encountered that
|
||||||
// did not allow to completely select the objects.
|
// did not allow to completely select the objects.
|
||||||
func (s *Shard) Select(prm *SelectPrm) (*SelectRes, error) {
|
func (s *Shard) Select(prm *SelectPrm) (*SelectRes, error) {
|
||||||
s.mtx.RLock()
|
|
||||||
defer s.mtx.RUnlock()
|
|
||||||
|
|
||||||
addrList, err := s.metaBase.Select(prm.filters)
|
addrList, err := s.metaBase.Select(prm.filters)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "could not select objects from metabase")
|
return nil, errors.Wrap(err, "could not select objects from metabase")
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package shard
|
package shard
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sync"
|
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
|
||||||
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
||||||
|
@ -12,8 +10,6 @@ import (
|
||||||
type Shard struct {
|
type Shard struct {
|
||||||
*cfg
|
*cfg
|
||||||
|
|
||||||
mtx *sync.RWMutex
|
|
||||||
|
|
||||||
weight WeightValues
|
weight WeightValues
|
||||||
|
|
||||||
blobStor *blobstor.BlobStor
|
blobStor *blobstor.BlobStor
|
||||||
|
@ -48,7 +44,6 @@ func New(opts ...Option) *Shard {
|
||||||
|
|
||||||
return &Shard{
|
return &Shard{
|
||||||
cfg: c,
|
cfg: c,
|
||||||
mtx: new(sync.RWMutex),
|
|
||||||
blobStor: blobstor.New(c.blobOpts...),
|
blobStor: blobstor.New(c.blobOpts...),
|
||||||
metaBase: meta.NewDB(c.metaOpts...),
|
metaBase: meta.NewDB(c.metaOpts...),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue