From 2ec04339d1ae441a00bc3ddbc271679d70baef36 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Tue, 20 Feb 2024 17:07:35 +0300 Subject: [PATCH] [#9999] metabase: Do not store all user attributes Signed-off-by: Dmitrii Stepanov --- pkg/local_object_storage/metabase/put.go | 4 + .../metabase/select_test.go | 125 ------------------ 2 files changed, 4 insertions(+), 125 deletions(-) diff --git a/pkg/local_object_storage/metabase/put.go b/pkg/local_object_storage/metabase/put.go index e87536921..7098874ad 100644 --- a/pkg/local_object_storage/metabase/put.go +++ b/pkg/local_object_storage/metabase/put.go @@ -8,6 +8,7 @@ import ( gio "io" "time" + objectV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/object" objectCore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object" storagelog "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/log" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/metaerr" @@ -322,6 +323,9 @@ func updateFKBTIndexes(tx *bbolt.Tx, obj *objectSDK.Object, f updateIndexItemFun // user specified attributes for i := range attrs { + if attrs[i].Key() != objectV2.SysAttributeExpEpoch { + continue + } key = attributeBucketName(cnr, attrs[i].Key(), key) err := f(tx, namedBucketItem{ name: key, diff --git a/pkg/local_object_storage/metabase/select_test.go b/pkg/local_object_storage/metabase/select_test.go index d29288cf8..a6597d5fa 100644 --- a/pkg/local_object_storage/metabase/select_test.go +++ b/pkg/local_object_storage/metabase/select_test.go @@ -19,131 +19,6 @@ import ( "github.com/stretchr/testify/require" ) -func TestDB_SelectUserAttributes(t *testing.T) { - t.Parallel() - - db := newDB(t) - defer func() { require.NoError(t, db.Close()) }() - - cnr := cidtest.ID() - - raw1 := testutil.GenerateObjectWithCID(cnr) - testutil.AddAttribute(raw1, "foo", "bar") - testutil.AddAttribute(raw1, "x", "y") - - err := putBig(db, raw1) - require.NoError(t, err) - - raw2 := testutil.GenerateObjectWithCID(cnr) - testutil.AddAttribute(raw2, "foo", "bar") - testutil.AddAttribute(raw2, "x", "z") - - err = putBig(db, raw2) - require.NoError(t, err) - - raw3 := testutil.GenerateObjectWithCID(cnr) - testutil.AddAttribute(raw3, "a", "b") - - err = putBig(db, raw3) - require.NoError(t, err) - - raw4 := testutil.GenerateObjectWithCID(cnr) - testutil.AddAttribute(raw4, "path", "test/1/2") - - err = putBig(db, raw4) - require.NoError(t, err) - - raw5 := testutil.GenerateObjectWithCID(cnr) - testutil.AddAttribute(raw5, "path", "test/1/3") - - err = putBig(db, raw5) - require.NoError(t, err) - - raw6 := testutil.GenerateObjectWithCID(cnr) - testutil.AddAttribute(raw6, "path", "test/2/3") - - err = putBig(db, raw6) - require.NoError(t, err) - - fs := objectSDK.SearchFilters{} - fs.AddFilter("foo", "bar", objectSDK.MatchStringEqual) - testSelect(t, db, cnr, fs, - object.AddressOf(raw1), - object.AddressOf(raw2), - ) - - fs = objectSDK.SearchFilters{} - fs.AddFilter("x", "y", objectSDK.MatchStringEqual) - testSelect(t, db, cnr, fs, object.AddressOf(raw1)) - - fs = objectSDK.SearchFilters{} - fs.AddFilter("x", "y", objectSDK.MatchStringNotEqual) - testSelect(t, db, cnr, fs, object.AddressOf(raw2)) - - fs = objectSDK.SearchFilters{} - fs.AddFilter("a", "b", objectSDK.MatchStringEqual) - testSelect(t, db, cnr, fs, object.AddressOf(raw3)) - - fs = objectSDK.SearchFilters{} - fs.AddFilter("c", "d", objectSDK.MatchStringEqual) - testSelect(t, db, cnr, fs) - - fs = objectSDK.SearchFilters{} - fs.AddFilter("foo", "", objectSDK.MatchNotPresent) - testSelect(t, db, cnr, fs, - object.AddressOf(raw3), - object.AddressOf(raw4), - object.AddressOf(raw5), - object.AddressOf(raw6), - ) - - fs = objectSDK.SearchFilters{} - fs.AddFilter("a", "", objectSDK.MatchNotPresent) - testSelect(t, db, cnr, fs, - object.AddressOf(raw1), - object.AddressOf(raw2), - object.AddressOf(raw4), - object.AddressOf(raw5), - object.AddressOf(raw6), - ) - - fs = objectSDK.SearchFilters{} - testSelect(t, db, cnr, fs, - object.AddressOf(raw1), - object.AddressOf(raw2), - object.AddressOf(raw3), - object.AddressOf(raw4), - object.AddressOf(raw5), - object.AddressOf(raw6), - ) - - fs = objectSDK.SearchFilters{} - fs.AddFilter("key", "", objectSDK.MatchNotPresent) - testSelect(t, db, cnr, fs, - object.AddressOf(raw1), - object.AddressOf(raw2), - object.AddressOf(raw3), - object.AddressOf(raw4), - object.AddressOf(raw5), - object.AddressOf(raw6), - ) - - fs = objectSDK.SearchFilters{} - fs.AddFilter("path", "test", objectSDK.MatchCommonPrefix) - testSelect(t, db, cnr, fs, - object.AddressOf(raw4), - object.AddressOf(raw5), - object.AddressOf(raw6), - ) - - fs = objectSDK.SearchFilters{} - fs.AddFilter("path", "test/1", objectSDK.MatchCommonPrefix) - testSelect(t, db, cnr, fs, - object.AddressOf(raw4), - object.AddressOf(raw5), - ) -} - func TestDB_SelectRootPhyParent(t *testing.T) { t.Parallel()