[#1632] node/container: Don't add new container to missed cache record

If container listing cache on node's side is missing (for particular
owner), then updating it as a reaction to successful container creation
leads to potentially invalid cache value for a period of time equivalent
to cache TTL.

Immediately return from `ttlContainerLister.update` method if owner's
container list isn't cached.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-08-16 18:54:19 +04:00 committed by LeL
parent fa3124fc33
commit ae6ebccd9c

View file

@ -317,15 +317,8 @@ func (s *ttlContainerLister) update(owner user.ID, cnr cid.ID, add bool) {
val, ok := (*ttlNetCache)(s).cache.Get(strOwner) val, ok := (*ttlNetCache)(s).cache.Get(strOwner)
if !ok { if !ok {
if add { // we could cache the single cnr but in this case we will disperse
// first cached owner's container // with the Sidechain a lot
(*ttlNetCache)(s).set(strOwner, &cacheItemContainerList{
list: []cid.ID{cnr},
}, nil)
}
// no-op on removal when no owner's containers are cached
return return
} }