From fa20c83f08a93efc52e718c5d7f5a74484f369a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Tue, 8 Oct 2024 11:33:59 +0200 Subject: [PATCH] Do not delete cache entries that shouldn't be deleted --- pkg/storage/fs/posix/lookup/store_idcache.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pkg/storage/fs/posix/lookup/store_idcache.go b/pkg/storage/fs/posix/lookup/store_idcache.go index eb6f3a5fd5..c3db2d286e 100644 --- a/pkg/storage/fs/posix/lookup/store_idcache.go +++ b/pkg/storage/fs/posix/lookup/store_idcache.go @@ -63,8 +63,23 @@ func (c *StoreIDCache) Delete(_ context.Context, spaceID, nodeID string) error { // DeleteByPath removes an entry from the cache func (c *StoreIDCache) DeleteByPath(ctx context.Context, path string) error { + spaceID, nodeID, ok := c.GetByPath(ctx, path) + if !ok { + appctx.GetLogger(ctx).Error().Str("record", path).Msg("could not get spaceID and nodeID from cache") + } else { + err := c.cache.Delete(reverseCacheKey(path)) + if err != nil { + appctx.GetLogger(ctx).Error().Err(err).Str("record", path).Str("spaceID", spaceID).Str("nodeID", nodeID).Msg("could not get spaceID and nodeID from cache") + } + + err = c.cache.Delete(cacheKey(spaceID, nodeID)) + if err != nil { + appctx.GetLogger(ctx).Error().Err(err).Str("record", path).Str("spaceID", spaceID).Str("nodeID", nodeID).Msg("could not get spaceID and nodeID from cache") + } + } + list, err := c.cache.List( - microstore.ListPrefix(reverseCacheKey(path)), + microstore.ListPrefix(reverseCacheKey(path) + "/"), ) if err != nil { return err