From fb99b2620983604ceb9938516a4356f0d90acc8f Mon Sep 17 00:00:00 2001 From: Artem Tataurov Date: Thu, 30 Mar 2023 18:34:58 +0300 Subject: [PATCH] [#57] api: Clean up List and Name caches when object is missing in Tree service --- CHANGELOG.md | 1 + api/layer/layer.go | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b89f88dc..af1d92bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ This document outlines major changes between releases. ## [Unreleased] ### Fixed +- Clean up List and Name caches when object is missing in Tree service (#57) - Get empty bucket CORS from frostfs (TrueCloudLab#36) - Don't count pool error on client abort (#35) diff --git a/api/layer/layer.go b/api/layer/layer.go index 0ea7aafe..165d1592 100644 --- a/api/layer/layer.go +++ b/api/layer/layer.go @@ -549,7 +549,7 @@ func (n *layer) deleteObject(ctx context.Context, bkt *data.BucketInfo, settings if len(obj.VersionID) != 0 || settings.Unversioned() { var nodeVersion *data.NodeVersion if nodeVersion, obj.Error = n.getNodeVersionToDelete(ctx, bkt, obj); obj.Error != nil { - return dismissNotFoundError(obj) + return n.handleNotFoundError(bkt, obj) } if obj.DeleteMarkVersion, obj.Error = n.removeOldVersion(ctx, bkt, nodeVersion, obj); obj.Error != nil { @@ -568,7 +568,7 @@ func (n *layer) deleteObject(ctx context.Context, bkt *data.BucketInfo, settings var nodeVersion *data.NodeVersion if nodeVersion, obj.Error = n.getNodeVersionToDelete(ctx, bkt, obj); obj.Error != nil { - return dismissNotFoundError(obj) + return n.handleNotFoundError(bkt, obj) } if obj.DeleteMarkVersion, obj.Error = n.removeOldVersion(ctx, bkt, nodeVersion, obj); obj.Error != nil { @@ -605,10 +605,12 @@ func (n *layer) deleteObject(ctx context.Context, bkt *data.BucketInfo, settings return obj } -func dismissNotFoundError(obj *VersionedObject) *VersionedObject { +func (n *layer) handleNotFoundError(bkt *data.BucketInfo, obj *VersionedObject) *VersionedObject { if errors.IsS3Error(obj.Error, errors.ErrNoSuchKey) || errors.IsS3Error(obj.Error, errors.ErrNoSuchVersion) { obj.Error = nil + n.cache.CleanListCacheEntriesContainingObject(obj.Name, bkt.CID) + n.cache.DeleteObjectName(bkt.CID, bkt.Name, obj.Name) } return obj