From 2b755ddb12f9fcd9b51a38ca79b5fa88cdab27ab Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 16 Feb 2023 16:04:53 +0300 Subject: [PATCH] [#2260] node: Use a separate client cache for PUT service Currently, under a mixed load one failed PUT can lead to closing connection for all concurrent GETs. For PUT it does no harm: we have many other nodes to choose from. For GET we are limited by `REP N` factor, so in case of failover we can close the connection with the only node posessing an object, which leads to failing the whole operation. Signed-off-by: Evgenii Stratonikov --- cmd/frostfs-node/config.go | 27 +++++++++++++++------------ cmd/frostfs-node/object.go | 10 +++++++++- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/cmd/frostfs-node/config.go b/cmd/frostfs-node/config.go index 80d506eee..7eb0e623a 100644 --- a/cmd/frostfs-node/config.go +++ b/cmd/frostfs-node/config.go @@ -342,9 +342,10 @@ type shared struct { privateTokenStore sessionStorage persistate *state.PersistentStorage - clientCache *cache.ClientCache - bgClientCache *cache.ClientCache - localAddr network.AddressGroup + clientCache *cache.ClientCache + bgClientCache *cache.ClientCache + putClientCache *cache.ClientCache + localAddr network.AddressGroup key *keys.PrivateKey binPublicKey []byte @@ -570,13 +571,14 @@ func initCfg(appCfg *config.Config) *cfg { ReconnectTimeout: apiclientconfig.ReconnectTimeout(appCfg), } c.shared = shared{ - key: key, - binPublicKey: key.PublicKey().Bytes(), - localAddr: netAddr, - respSvc: response.NewService(response.WithNetworkState(netState)), - clientCache: cache.NewSDKClientCache(cacheOpts), - bgClientCache: cache.NewSDKClientCache(cacheOpts), - persistate: persistate, + key: key, + binPublicKey: key.PublicKey().Bytes(), + localAddr: netAddr, + respSvc: response.NewService(response.WithNetworkState(netState)), + clientCache: cache.NewSDKClientCache(cacheOpts), + bgClientCache: cache.NewSDKClientCache(cacheOpts), + putClientCache: cache.NewSDKClientCache(cacheOpts), + persistate: persistate, } c.cfgAccounting = cfgAccounting{ scriptHash: contractsconfig.Balance(appCfg), @@ -615,8 +617,9 @@ func initCfg(appCfg *config.Config) *cfg { netState.metrics = c.metricsCollector } - c.onShutdown(c.clientCache.CloseAll) // clean up connections - c.onShutdown(c.bgClientCache.CloseAll) // clean up connections + c.onShutdown(c.clientCache.CloseAll) // clean up connections + c.onShutdown(c.bgClientCache.CloseAll) // clean up connections + c.onShutdown(c.putClientCache.CloseAll) // clean up connections c.onShutdown(func() { _ = c.persistate.Close() }) return c diff --git a/cmd/frostfs-node/object.go b/cmd/frostfs-node/object.go index d9a8adf20..12d367e19 100644 --- a/cmd/frostfs-node/object.go +++ b/cmd/frostfs-node/object.go @@ -182,6 +182,14 @@ func initObjectService(c *cfg) { basicConstructor: c.clientCache, } + putConstructor := &coreClientConstructor{ + log: c.log, + nmSrc: c.netMapSource, + netState: c.cfgNetmap.state, + trustStorage: c.cfgReputation.localTrustStorage, + basicConstructor: c.putClientCache, + } + var irFetcher v2.InnerRingFetcher if c.cfgMorph.client.ProbeNotary() { @@ -255,7 +263,7 @@ func initObjectService(c *cfg) { sPut := putsvc.NewService( putsvc.WithKeyStorage(keyStorage), - putsvc.WithClientConstructor(coreConstructor), + putsvc.WithClientConstructor(putConstructor), putsvc.WithMaxSizeSource(newCachedMaxObjectSizeSource(c)), putsvc.WithObjectStorage(os), putsvc.WithContainerSource(c.cfgObject.cnrSource),