[#2048] neofs-node: Use a separate client cache for client operations

Background workers can prevent user operations to complete because of
locking in cache.

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
Evgenii Stratonikov 2022-11-12 10:46:23 +03:00 committed by fyrchik
parent d5a14041e0
commit 597ed18269
5 changed files with 31 additions and 19 deletions

View file

@ -8,6 +8,7 @@ Changelog for NeoFS Node
- `--binary` flag in `neofs-cli object put/get/delete` commands (#1338) - `--binary` flag in `neofs-cli object put/get/delete` commands (#1338)
- `session` flag support to `neofs-cli object hash` (#2029) - `session` flag support to `neofs-cli object hash` (#2029)
- Shard can now change mode when encountering background disk errors (#2035) - Shard can now change mode when encountering background disk errors (#2035)
- Background workers and object service now use separate client caches (#2048)
### Changed ### Changed
- `object lock` command reads CID and OID the same way other commands do (#1971) - `object lock` command reads CID and OID the same way other commands do (#1971)

View file

@ -342,6 +342,7 @@ type shared struct {
persistate *state.PersistentStorage persistate *state.PersistentStorage
clientCache *cache.ClientCache clientCache *cache.ClientCache
bgClientCache *cache.ClientCache
localAddr network.AddressGroup localAddr network.AddressGroup
key *keys.PrivateKey key *keys.PrivateKey
@ -555,17 +556,20 @@ func initCfg(appCfg *config.Config) *cfg {
apiVersion: version.Current(), apiVersion: version.Current(),
healthStatus: atomic.NewInt32(int32(control.HealthStatus_HEALTH_STATUS_UNDEFINED)), healthStatus: atomic.NewInt32(int32(control.HealthStatus_HEALTH_STATUS_UNDEFINED)),
} }
cacheOpts := cache.ClientCacheOpts{
DialTimeout: apiclientconfig.DialTimeout(appCfg),
StreamTimeout: apiclientconfig.StreamTimeout(appCfg),
Key: &key.PrivateKey,
AllowExternal: apiclientconfig.AllowExternal(appCfg),
}
c.shared = shared{ c.shared = shared{
key: key, key: key,
binPublicKey: key.PublicKey().Bytes(), binPublicKey: key.PublicKey().Bytes(),
localAddr: netAddr, localAddr: netAddr,
respSvc: response.NewService(response.WithNetworkState(netState)), respSvc: response.NewService(response.WithNetworkState(netState)),
clientCache: cache.NewSDKClientCache(cache.ClientCacheOpts{ clientCache: cache.NewSDKClientCache(cacheOpts),
DialTimeout: apiclientconfig.DialTimeout(appCfg), bgClientCache: cache.NewSDKClientCache(cacheOpts),
StreamTimeout: apiclientconfig.StreamTimeout(appCfg),
Key: &key.PrivateKey,
AllowExternal: apiclientconfig.AllowExternal(appCfg),
}),
persistate: persistate, persistate: persistate,
} }
c.cfgAccounting = cfgAccounting{ c.cfgAccounting = cfgAccounting{
@ -605,6 +609,7 @@ func initCfg(appCfg *config.Config) *cfg {
} }
c.onShutdown(c.clientCache.CloseAll) // clean up connections c.onShutdown(c.clientCache.CloseAll) // clean up connections
c.onShutdown(c.bgClientCache.CloseAll) // clean up connections
c.onShutdown(func() { _ = c.persistate.Close() }) c.onShutdown(func() { _ = c.persistate.Close() })
return c return c

View file

@ -162,7 +162,7 @@ func initContainerService(c *cfg) {
RemoteWriterProvider: &remoteLoadAnnounceProvider{ RemoteWriterProvider: &remoteLoadAnnounceProvider{
key: &c.key.PrivateKey, key: &c.key.PrivateKey,
netmapKeys: c, netmapKeys: c,
clientCache: c.clientCache, clientCache: c.bgClientCache,
deadEndProvider: loadcontroller.SimpleWriterProvider(loadAccumulator), deadEndProvider: loadcontroller.SimpleWriterProvider(loadAccumulator),
}, },
Builder: routeBuilder, Builder: routeBuilder,

View file

@ -171,10 +171,16 @@ func initObjectService(c *cfg) {
nmSrc: c.netMapSource, nmSrc: c.netMapSource,
netState: c.cfgNetmap.state, netState: c.cfgNetmap.state,
trustStorage: c.cfgReputation.localTrustStorage, trustStorage: c.cfgReputation.localTrustStorage,
basicConstructor: c.clientCache, basicConstructor: c.bgClientCache,
} }
coreConstructor := (*coreClientConstructor)(clientConstructor) coreConstructor := &coreClientConstructor{
log: c.log,
nmSrc: c.netMapSource,
netState: c.cfgNetmap.state,
trustStorage: c.cfgReputation.localTrustStorage,
basicConstructor: c.clientCache,
}
var irFetcher v2.InnerRingFetcher var irFetcher v2.InnerRingFetcher

View file

@ -95,7 +95,7 @@ func initReputationService(c *cfg) {
common.RemoteProviderPrm{ common.RemoteProviderPrm{
NetmapKeys: c, NetmapKeys: c,
DeadEndProvider: daughterStorageWriterProvider, DeadEndProvider: daughterStorageWriterProvider,
ClientCache: c.clientCache, ClientCache: c.bgClientCache,
WriterProvider: localreputation.NewRemoteProvider( WriterProvider: localreputation.NewRemoteProvider(
localreputation.RemoteProviderPrm{ localreputation.RemoteProviderPrm{
Key: &c.key.PrivateKey, Key: &c.key.PrivateKey,
@ -110,7 +110,7 @@ func initReputationService(c *cfg) {
common.RemoteProviderPrm{ common.RemoteProviderPrm{
NetmapKeys: c, NetmapKeys: c,
DeadEndProvider: consumerStorageWriterProvider, DeadEndProvider: consumerStorageWriterProvider,
ClientCache: c.clientCache, ClientCache: c.bgClientCache,
WriterProvider: intermediatereputation.NewRemoteProvider( WriterProvider: intermediatereputation.NewRemoteProvider(
intermediatereputation.RemoteProviderPrm{ intermediatereputation.RemoteProviderPrm{
Key: &c.key.PrivateKey, Key: &c.key.PrivateKey,