diff --git a/cmd/frostfs-node/cache.go b/cmd/frostfs-node/cache.go index dfbaf3525c..bae38b2999 100644 --- a/cmd/frostfs-node/cache.go +++ b/cmd/frostfs-node/cache.go @@ -25,19 +25,18 @@ type valueWithTime[V any] struct { } type locker struct { - mtx *sync.Mutex + mtx sync.Mutex waiters int // not protected by mtx, must used outer mutex to update concurrently } type keyLocker[K comparable] struct { lockers map[K]*locker - lockersMtx *sync.Mutex + lockersMtx sync.Mutex } func newKeyLocker[K comparable]() *keyLocker[K] { return &keyLocker[K]{ - lockers: make(map[K]*locker), - lockersMtx: &sync.Mutex{}, + lockers: make(map[K]*locker), } } @@ -53,7 +52,6 @@ func (l *keyLocker[K]) LockKey(key K) { } locker := &locker{ - mtx: &sync.Mutex{}, waiters: 1, } locker.mtx.Lock() diff --git a/cmd/frostfs-node/config.go b/cmd/frostfs-node/config.go index 30d4579676..00ade7ce21 100644 --- a/cmd/frostfs-node/config.go +++ b/cmd/frostfs-node/config.go @@ -327,7 +327,7 @@ type internals struct { log *logger.Logger - wg *sync.WaitGroup + wg sync.WaitGroup workers []worker closers []closer @@ -589,7 +589,6 @@ func initInternals(appCfg *config.Config, log *logger.Logger) internals { appCfg: appCfg, internalErr: make(chan error), log: log, - wg: new(sync.WaitGroup), apiVersion: version.Current(), healthStatus: &healthStatus, } diff --git a/pkg/innerring/processors/alphabet/processor.go b/pkg/innerring/processors/alphabet/processor.go index 972f842818..04dde80f72 100644 --- a/pkg/innerring/processors/alphabet/processor.go +++ b/pkg/innerring/processors/alphabet/processor.go @@ -49,7 +49,7 @@ type ( Processor struct { parsedWallets []util.Uint160 // protects parsedWallets from concurrent change - pwLock *sync.RWMutex + pwLock sync.RWMutex log *logger.Logger metrics metrics.Register pool *ants.Pool @@ -99,7 +99,6 @@ func New(p *Params) (*Processor, error) { return &Processor{ parsedWallets: p.ParsedWallets, - pwLock: new(sync.RWMutex), log: p.Log, metrics: metricsRegister, pool: pool, diff --git a/pkg/innerring/processors/frostfs/processor.go b/pkg/innerring/processors/frostfs/processor.go index e6ee78837e..20f44adcd8 100644 --- a/pkg/innerring/processors/frostfs/processor.go +++ b/pkg/innerring/processors/frostfs/processor.go @@ -68,7 +68,7 @@ type ( epochState EpochState alphabetState AlphabetState converter PrecisionConverter - mintEmitLock *sync.Mutex + mintEmitLock sync.Mutex mintEmitCache *lru.Cache[string, uint64] mintEmitThreshold uint64 mintEmitValue fixedn.Fixed8 @@ -148,7 +148,6 @@ func New(p *Params) (*Processor, error) { epochState: p.EpochState, alphabetState: p.AlphabetState, converter: p.Converter, - mintEmitLock: new(sync.Mutex), mintEmitCache: lruCache, mintEmitThreshold: p.MintEmitThreshold, mintEmitValue: p.MintEmitValue, diff --git a/pkg/innerring/processors/netmap/cleanup_table.go b/pkg/innerring/processors/netmap/cleanup_table.go index e4024e95f7..80117247dc 100644 --- a/pkg/innerring/processors/netmap/cleanup_table.go +++ b/pkg/innerring/processors/netmap/cleanup_table.go @@ -9,7 +9,7 @@ import ( type ( cleanupTable struct { - *sync.RWMutex + sync.RWMutex enabled bool threshold uint64 lastAccess map[string]epochStampWithNodeInfo @@ -29,7 +29,6 @@ type ( func newCleanupTable(enabled bool, threshold uint64) cleanupTable { return cleanupTable{ - RWMutex: new(sync.RWMutex), enabled: enabled, threshold: threshold, lastAccess: make(map[string]epochStampWithNodeInfo), diff --git a/pkg/local_object_storage/engine/engine.go b/pkg/local_object_storage/engine/engine.go index 19e7b5237f..21e863005d 100644 --- a/pkg/local_object_storage/engine/engine.go +++ b/pkg/local_object_storage/engine/engine.go @@ -20,7 +20,7 @@ type StorageEngine struct { removeDuplicatesInProgress atomic.Bool - mtx *sync.RWMutex + mtx sync.RWMutex shards map[string]hashedShard @@ -225,15 +225,12 @@ func New(opts ...Option) *StorageEngine { } return &StorageEngine{ - cfg: c, - mtx: new(sync.RWMutex), - shards: make(map[string]hashedShard), - shardPools: make(map[string]util.WorkerPool), - closeCh: make(chan struct{}), - setModeCh: make(chan setModeRequest), - evacuateLimiter: &evacuationLimiter{ - guard: &sync.RWMutex{}, - }, + cfg: c, + shards: make(map[string]hashedShard), + shardPools: make(map[string]util.WorkerPool), + closeCh: make(chan struct{}), + setModeCh: make(chan setModeRequest), + evacuateLimiter: &evacuationLimiter{}, } } diff --git a/pkg/local_object_storage/engine/evacuate_limiter.go b/pkg/local_object_storage/engine/evacuate_limiter.go index 425fdc7757..62795fa1a6 100644 --- a/pkg/local_object_storage/engine/evacuate_limiter.go +++ b/pkg/local_object_storage/engine/evacuate_limiter.go @@ -113,7 +113,7 @@ type evacuationLimiter struct { eg *errgroup.Group cancel context.CancelFunc - guard *sync.RWMutex + guard sync.RWMutex } func (l *evacuationLimiter) TryStart(ctx context.Context, shardIDs []string, result *EvacuateShardRes) (*errgroup.Group, context.Context, error) { diff --git a/pkg/morph/client/client.go b/pkg/morph/client/client.go index 6b6e1284be..de29d0c03f 100644 --- a/pkg/morph/client/client.go +++ b/pkg/morph/client/client.go @@ -66,7 +66,7 @@ type Client struct { // switchLock protects endpoints, inactive, and subscription-related fields. // It is taken exclusively during endpoint switch and locked in shared mode // on every normal call. - switchLock *sync.RWMutex + switchLock sync.RWMutex // channel for internal stop closeChan chan struct{} @@ -83,7 +83,7 @@ type Client struct { } type cache struct { - m *sync.RWMutex + m sync.RWMutex nnsHash *util.Uint160 gKey *keys.PublicKey diff --git a/pkg/morph/client/constructor.go b/pkg/morph/client/constructor.go index 1f2a1eb8db..ff37da728f 100644 --- a/pkg/morph/client/constructor.go +++ b/pkg/morph/client/constructor.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "sync" "time" "git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs" @@ -105,13 +104,12 @@ func New(ctx context.Context, key *keys.PrivateKey, opts ...Option) (*Client, er } cli := &Client{ - cache: newClientCache(), - logger: cfg.logger, - acc: acc, - accAddr: accAddr, - cfg: *cfg, - switchLock: &sync.RWMutex{}, - closeChan: make(chan struct{}), + cache: newClientCache(), + logger: cfg.logger, + acc: acc, + accAddr: accAddr, + cfg: *cfg, + closeChan: make(chan struct{}), } cli.endpoints.init(cfg.endpoints) @@ -198,7 +196,6 @@ func newActor(ws *rpcclient.WSClient, acc *wallet.Account, cfg cfg) (*actor.Acto func newClientCache() cache { c, _ := lru.New[util.Uint256, uint32](100) // returns error only if size is negative return cache{ - m: &sync.RWMutex{}, txHeights: c, } } diff --git a/pkg/morph/subscriber/subscriber.go b/pkg/morph/subscriber/subscriber.go index 383d58407f..608872dec7 100644 --- a/pkg/morph/subscriber/subscriber.go +++ b/pkg/morph/subscriber/subscriber.go @@ -42,7 +42,7 @@ type ( } subscriber struct { - *sync.RWMutex + sync.RWMutex log *logger.Logger client *client.Client @@ -163,7 +163,6 @@ func New(ctx context.Context, p *Params) (Subscriber, error) { } sub := &subscriber{ - RWMutex: new(sync.RWMutex), log: p.Log, client: p.Client, notifyChan: make(chan *state.ContainedNotificationEvent), diff --git a/pkg/morph/timer/block.go b/pkg/morph/timer/block.go index 31c28e2ffc..be20d35713 100644 --- a/pkg/morph/timer/block.go +++ b/pkg/morph/timer/block.go @@ -17,7 +17,7 @@ type BlockTickHandler func() type BlockTimer struct { rolledBack bool - mtx *sync.Mutex + mtx sync.Mutex dur BlockMeter @@ -64,7 +64,6 @@ func StaticBlockMeter(d uint32) BlockMeter { // Reset should be called before timer ticking. func NewBlockTimer(dur BlockMeter, h BlockTickHandler) *BlockTimer { return &BlockTimer{ - mtx: new(sync.Mutex), dur: dur, mul: 1, div: 1, @@ -80,7 +79,6 @@ func NewBlockTimer(dur BlockMeter, h BlockTickHandler) *BlockTimer { // Do not use delta handlers with pulse in this timer. func NewOneTickTimer(dur BlockMeter, h BlockTickHandler) *BlockTimer { return &BlockTimer{ - mtx: new(sync.Mutex), dur: dur, mul: 1, div: 1, diff --git a/pkg/services/notificator/nats/service.go b/pkg/services/notificator/nats/service.go index 6a7e80a533..19f0cbde19 100644 --- a/pkg/services/notificator/nats/service.go +++ b/pkg/services/notificator/nats/service.go @@ -25,7 +25,7 @@ type Writer struct { js nats.JetStreamContext nc *nats.Conn - m *sync.RWMutex + m sync.RWMutex createdStreams map[string]struct{} opts } @@ -84,7 +84,6 @@ func (n *Writer) Notify(topic string, address oid.Address) error { // New creates new Writer. func New(oo ...Option) *Writer { w := &Writer{ - m: &sync.RWMutex{}, createdStreams: make(map[string]struct{}), opts: opts{ log: &logger.Logger{Logger: zap.L()}, diff --git a/pkg/services/object/get/v2/get_forwarder.go b/pkg/services/object/get/v2/get_forwarder.go index d11f94b267..bc27f69a2a 100644 --- a/pkg/services/object/get/v2/get_forwarder.go +++ b/pkg/services/object/get/v2/get_forwarder.go @@ -23,8 +23,8 @@ import ( ) type getRequestForwarder struct { - OnceResign *sync.Once - OnceHeaderSending *sync.Once + OnceResign sync.Once + OnceHeaderSending sync.Once GlobalProgress int Key *ecdsa.PrivateKey Request *objectV2.GetRequest diff --git a/pkg/services/object/get/v2/get_range_forwarder.go b/pkg/services/object/get/v2/get_range_forwarder.go index 6c744b23a4..1137ba33c9 100644 --- a/pkg/services/object/get/v2/get_range_forwarder.go +++ b/pkg/services/object/get/v2/get_range_forwarder.go @@ -23,7 +23,7 @@ import ( ) type getRangeRequestForwarder struct { - OnceResign *sync.Once + OnceResign sync.Once GlobalProgress int Key *ecdsa.PrivateKey Request *objectV2.GetRangeRequest diff --git a/pkg/services/object/get/v2/head_forwarder.go b/pkg/services/object/get/v2/head_forwarder.go index 0c91ec5d81..1b0374aea5 100644 --- a/pkg/services/object/get/v2/head_forwarder.go +++ b/pkg/services/object/get/v2/head_forwarder.go @@ -25,7 +25,7 @@ import ( type headRequestForwarder struct { Request *objectV2.HeadRequest Response *objectV2.HeadResponse - OnceResign *sync.Once + OnceResign sync.Once ObjectAddr oid.Address Key *ecdsa.PrivateKey } diff --git a/pkg/services/object/get/v2/util.go b/pkg/services/object/get/v2/util.go index 91e7a96a25..519d9afa03 100644 --- a/pkg/services/object/get/v2/util.go +++ b/pkg/services/object/get/v2/util.go @@ -5,7 +5,6 @@ import ( "crypto/sha256" "errors" "hash" - "sync" objectV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/object" "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs" @@ -59,12 +58,10 @@ func (s *Service) toPrm(req *objectV2.GetRequest, stream objectSvc.GetObjectStre } forwarder := &getRequestForwarder{ - OnceResign: &sync.Once{}, - OnceHeaderSending: &sync.Once{}, - GlobalProgress: 0, - Key: key, - Request: req, - Stream: streamWrapper, + GlobalProgress: 0, + Key: key, + Request: req, + Stream: streamWrapper, } p.SetRequestForwarder(groupAddressRequestForwarder(forwarder.forwardRequestToNode)) @@ -115,7 +112,6 @@ func (s *Service) toRangePrm(req *objectV2.GetRangeRequest, stream objectSvc.Get } forwarder := &getRangeRequestForwarder{ - OnceResign: &sync.Once{}, GlobalProgress: 0, Key: key, Request: req, @@ -254,7 +250,6 @@ func (s *Service) toHeadPrm(req *objectV2.HeadRequest, resp *objectV2.HeadRespon forwarder := &headRequestForwarder{ Request: req, Response: resp, - OnceResign: &sync.Once{}, ObjectAddr: objAddr, Key: key, } diff --git a/pkg/services/object/search/v2/request_forwarder.go b/pkg/services/object/search/v2/request_forwarder.go index d8719986f5..5a2e9b936d 100644 --- a/pkg/services/object/search/v2/request_forwarder.go +++ b/pkg/services/object/search/v2/request_forwarder.go @@ -20,7 +20,7 @@ import ( ) type requestForwarder struct { - OnceResign *sync.Once + OnceResign sync.Once Request *objectV2.SearchRequest Key *ecdsa.PrivateKey } diff --git a/pkg/services/object/search/v2/util.go b/pkg/services/object/search/v2/util.go index 12158a820a..cfccaede65 100644 --- a/pkg/services/object/search/v2/util.go +++ b/pkg/services/object/search/v2/util.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "sync" objectV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/object" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/client" @@ -51,9 +50,8 @@ func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStre } forwarder := &requestForwarder{ - OnceResign: &sync.Once{}, - Request: req, - Key: key, + Request: req, + Key: key, } p.SetRequestForwarder(groupAddressRequestForwarder(forwarder.forwardRequest)) diff --git a/pkg/services/object_manager/placement/traverser.go b/pkg/services/object_manager/placement/traverser.go index e46240a86b..7b9b26a0b3 100644 --- a/pkg/services/object_manager/placement/traverser.go +++ b/pkg/services/object_manager/placement/traverser.go @@ -29,7 +29,7 @@ type Option func(*cfg) // Traverser represents utility for controlling // traversal of object placement vectors. type Traverser struct { - mtx *sync.RWMutex + mtx sync.RWMutex vectors [][]netmap.NodeInfo @@ -107,7 +107,6 @@ func NewTraverser(opts ...Option) (*Traverser, error) { } return &Traverser{ - mtx: new(sync.RWMutex), rem: rem, vectors: ns, }, nil diff --git a/pkg/services/session/storage/temporary/storage.go b/pkg/services/session/storage/temporary/storage.go index 370499e062..ee93dee71a 100644 --- a/pkg/services/session/storage/temporary/storage.go +++ b/pkg/services/session/storage/temporary/storage.go @@ -18,7 +18,7 @@ type key struct { // expiring (removing) session tokens. // Must be created only via calling NewTokenStore. type TokenStore struct { - mtx *sync.RWMutex + mtx sync.RWMutex tokens map[key]*storage.PrivateToken } @@ -28,7 +28,6 @@ type TokenStore struct { // The elements of the instance are stored in the map. func NewTokenStore() *TokenStore { return &TokenStore{ - mtx: new(sync.RWMutex), tokens: make(map[key]*storage.PrivateToken), } }