From da8da1c63ad581203f27d44f5006a2b1f9caebf0 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Tue, 21 Mar 2023 21:31:48 +0300 Subject: [PATCH] [#98] fstree: Do not fail iteration over just removed files A directory is read and files are saved to a local variable. The iteration over such files may lead to a non-existing files reading due to a normal SN operation cycle and, therefore, may lead to a returning the OS error to a caller. Skip just removed (or lost) files as the golang std library does in similar situations: https://github.com/golang/go/blob/5f1a0320b92a60ee1283522135e00bff540ea115/src/os/dir_unix.go#L128-L133. Signed-off-by: Pavel Karpy --- CHANGELOG.md | 1 + pkg/local_object_storage/blobstor/fstree/fstree.go | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfc4eaf43..f1ba8aaf9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ Changelog for FrostFS Node - Actually use `object.put.pool_size_local` and independent pool for local puts (#64). - Pretty printer of basic ACL in the NeoFS CLI (#2259) - Adding of public key for nns group `group.frostfs` at init step (#130) +- Iterating over just removed files by FSTree (#98) ### Removed ### Updated diff --git a/pkg/local_object_storage/blobstor/fstree/fstree.go b/pkg/local_object_storage/blobstor/fstree/fstree.go index 3265e68f3..1a1247001 100644 --- a/pkg/local_object_storage/blobstor/fstree/fstree.go +++ b/pkg/local_object_storage/blobstor/fstree/fstree.go @@ -135,13 +135,16 @@ func (t *FSTree) iterate(depth uint64, curPath []string, prm common.IteratePrm) continue } + data, err := os.ReadFile(filepath.Join(curPath...)) + if err != nil && os.IsNotExist(err) { + continue + } + if prm.LazyHandler != nil { err = prm.LazyHandler(addr, func() ([]byte, error) { - return os.ReadFile(filepath.Join(curPath...)) + return data, err }) } else { - var data []byte - data, err = os.ReadFile(filepath.Join(curPath...)) if err == nil { data, err = t.Decompress(data) }