From 76cf7a051b9bd33997dfb21df46e727e3a6cda38 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Mon, 17 Jun 2024 09:47:53 +0300 Subject: [PATCH] [#1178] shard: Check metabase existence before read shard ID Signed-off-by: Dmitrii Stepanov --- pkg/local_object_storage/metabase/shard_id.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/local_object_storage/metabase/shard_id.go b/pkg/local_object_storage/metabase/shard_id.go index 9b24e98d..88446494 100644 --- a/pkg/local_object_storage/metabase/shard_id.go +++ b/pkg/local_object_storage/metabase/shard_id.go @@ -4,6 +4,7 @@ import ( "bytes" "errors" "fmt" + "os" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/metaerr" metamode "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode" @@ -25,6 +26,10 @@ func (db *DB) GetShardID(mode metamode.Mode) ([]byte, error) { defer db.modeMtx.Unlock() db.mode = mode + if _, err := os.Stat(db.info.Path); errors.Is(err, os.ErrNotExist) { + return nil, nil + } + if err := db.openDB(mode); err != nil { return nil, fmt.Errorf("failed to open metabase: %w", err) }