forked from TrueCloudLab/frostfs-node
[#2176] neofs-node: Do not cache full container list
We rarely need to list all containers: as one example we need it for tree service synchronization once per epoch. Given that cache TTL has the order of block time it makes no sense to cache the list of all containers. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
8078af3424
commit
072a7d61ab
2 changed files with 10 additions and 10 deletions
|
@ -58,7 +58,8 @@ Changelog for FrostFS Node
|
||||||
- Use `sync.Pool` in Object.PUT service (#2139)
|
- Use `sync.Pool` in Object.PUT service (#2139)
|
||||||
- Shard uses metabase for `HEAD` requests by default, not write-cache (#2167)
|
- Shard uses metabase for `HEAD` requests by default, not write-cache (#2167)
|
||||||
- Clarify help for `--expire-at` parameter for commands `object lock/put` and `bearer create` (#2097)
|
- Clarify help for `--expire-at` parameter for commands `object lock/put` and `bearer create` (#2097)
|
||||||
- Node spawns `GETRANGE` requests signed with the node's key if session key was not found for `RANGEHASH` (#2144)
|
- Node spawns `GETRANGE` requests signed with the node's key if session key was not found for `RANGEHASH` (#2144)
|
||||||
|
- Full list of container is no longer cached (#2176)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Open FSTree in sync mode by default (#1992)
|
- Open FSTree in sync mode by default (#1992)
|
||||||
|
|
|
@ -215,7 +215,8 @@ func (s *lruNetmapSource) Epoch() (uint64, error) {
|
||||||
// wrapper over TTL cache of values read from the network
|
// wrapper over TTL cache of values read from the network
|
||||||
// that implements container lister.
|
// that implements container lister.
|
||||||
type ttlContainerLister struct {
|
type ttlContainerLister struct {
|
||||||
*ttlNetCache[string, *cacheItemContainerList]
|
inner *ttlNetCache[string, *cacheItemContainerList]
|
||||||
|
client *cntClient.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// value type for ttlNetCache used by ttlContainerLister.
|
// value type for ttlNetCache used by ttlContainerLister.
|
||||||
|
@ -251,20 +252,18 @@ func newCachedContainerLister(c *cntClient.Client, ttl time.Duration) ttlContain
|
||||||
}, nil
|
}, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
return ttlContainerLister{lruCnrListerCache}
|
return ttlContainerLister{inner: lruCnrListerCache, client: c}
|
||||||
}
|
}
|
||||||
|
|
||||||
// List returns list of container IDs from the cache. If list is missing in the
|
// List returns list of container IDs from the cache. If list is missing in the
|
||||||
// cache or expired, then it returns container IDs from side chain and updates
|
// cache or expired, then it returns container IDs from side chain and updates
|
||||||
// the cache.
|
// the cache.
|
||||||
func (s ttlContainerLister) List(id *user.ID) ([]cid.ID, error) {
|
func (s ttlContainerLister) List(id *user.ID) ([]cid.ID, error) {
|
||||||
var str string
|
if id == nil {
|
||||||
|
return s.client.List(nil)
|
||||||
if id != nil {
|
|
||||||
str = id.EncodeToString()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
item, err := s.get(str)
|
item, err := s.inner.get(id.EncodeToString())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -287,14 +286,14 @@ func (s ttlContainerLister) List(id *user.ID) ([]cid.ID, error) {
|
||||||
func (s *ttlContainerLister) update(owner user.ID, cnr cid.ID, add bool) {
|
func (s *ttlContainerLister) update(owner user.ID, cnr cid.ID, add bool) {
|
||||||
strOwner := owner.EncodeToString()
|
strOwner := owner.EncodeToString()
|
||||||
|
|
||||||
val, ok := s.cache.Peek(strOwner)
|
val, ok := s.inner.cache.Peek(strOwner)
|
||||||
if !ok {
|
if !ok {
|
||||||
// we could cache the single cnr but in this case we will disperse
|
// we could cache the single cnr but in this case we will disperse
|
||||||
// with the Sidechain a lot
|
// with the Sidechain a lot
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.ttl <= time.Since(val.t) {
|
if s.inner.ttl <= time.Since(val.t) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue