[#506] node: Invalidate list cache after container add/removal

`update` already has problems mentioned in its doc-comment and the code
itself is not straightforward. Invalidating cache altogether seems like
a better option because we don't construct cache output ourselves (thus, no
"impossible" results).

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-11-14 14:35:23 +03:00 committed by Evgenii Stratonikov
parent f13f5d3b0f
commit b62008daca
2 changed files with 4 additions and 46 deletions

View file

@ -74,7 +74,7 @@ func configureEACLAndContainerSources(c *cfg, client *cntClient.Client, cnrSrc c
// creation success are most commonly tracked by polling GET op.
cnr, err := cnrSrc.Get(ev.ID)
if err == nil {
cachedContainerLister.update(cnr.Value.Owner(), ev.ID, true)
cachedContainerLister.invalidate(cnr.Value.Owner())
cachedContainerStorage.containerCache.set(ev.ID, cnr, nil)
} else {
// unlike removal, we expect successful receive of the container
@ -96,7 +96,7 @@ func configureEACLAndContainerSources(c *cfg, client *cntClient.Client, cnrSrc c
cachedContainerStorage.handleRemoval(ev.ID)
info, err := cachedContainerStorage.DeletionInfo(ev.ID)
if err == nil {
cachedContainerLister.update(info.Owner, ev.ID, false)
cachedContainerLister.invalidate(info.Owner)
}
c.log.Debug(logs.FrostFSNodeContainerRemovalEventsReceipt,