Skip to content

metabase: store associated object field in bytes #3971

Open
End-rey wants to merge 2 commits intomasterfrom
associated-object-field-format
Open

metabase: store associated object field in bytes #3971
End-rey wants to merge 2 commits intomasterfrom
associated-object-field-format

Conversation

@End-rey
Copy link
Copy Markdown
Contributor

@End-rey End-rey commented Apr 29, 2026

Closes #3926.

Signed-off-by: Andrey Butusov <andrey@nspcc.io>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

❌ Patch coverage is 54.20561% with 49 lines in your changes missing coverage. Please review.
✅ Project coverage is 28.06%. Comparing base (ec8b66e) to head (bec2d00).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
pkg/local_object_storage/metabase/version.go 51.76% 30 Missing and 11 partials ⚠️
pkg/core/object/metadata.go 0.00% 3 Missing ⚠️
pkg/local_object_storage/metabase/get.go 60.00% 1 Missing and 1 partial ⚠️
pkg/local_object_storage/metabase/metadata.go 81.81% 1 Missing and 1 partial ⚠️
pkg/util/meta/test/metatest.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3971      +/-   ##
==========================================
+ Coverage   27.72%   28.06%   +0.34%     
==========================================
  Files         676      680       +4     
  Lines       44962    45390     +428     
==========================================
+ Hits        12465    12740     +275     
- Misses      31367    31459      +92     
- Partials     1130     1191      +61     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

case object.FilterPhysical, object.FilterRoot:
// Not real attributes, ignored.
default:
if string(attrKey) == object.AttributeAssociatedObject && len(attrVal) == oid.Size {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it's a natural part of the switch above, isn't it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

cnr := cidtest.ID()

o := objecttest.Object()
o.ResetRelations()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we need to fix objecttest or have some local regular test object function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used existing helpers.

target := obj.AssociatedObject()
if target.IsZero() {
return nil
return fmt.Errorf("%s object has zero associated object", obj.Type())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somewhat different problem, this nil was relevant before 5675b9d, now it's obsolete, yes.


func migrateAssociatedObjectValueToIDBytes(l *zap.Logger, _ *bbolt.Tx, b *bbolt.Bucket, cnr cid.ID, afterKey []byte, rem uint) (uint, []byte, error) {
c := b.Cursor()
k, _ := c.First()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Position to associated ID prefix immediately, then you have AttrID and you can get IDAttr to change from it as well. You don't want to scan the whole DB, in fact this attribute is pretty rare.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Store `__NEOFS__ASSOCIATE` in metabase as raw OID bytes instead of Base58.
Reject non-OID values for this attribute, add migration, update read/search
paths and cover the new layout in tests.

```
goos: linux
goarch: amd64
pkg: github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase
cpu: AMD Ryzen 7 PRO 4750U with Radeon Graphics
                                           │    old.txt    │               new.txt               │
                                           │    sec/op     │   sec/op     vs base                │
Search/user_attribute-16                      17.76µ ±  2%   15.10µ ± 2%  -15.00% (p=0.000 n=10)
Search/associated_object_with_attribute-16    13.25µ ±  2%   15.20µ ± 8%  +14.68% (p=0.000 n=10)
IsLocked/locked-16                           11.464µ ±  2%   5.303µ ± 5%  -53.75% (p=0.000 n=10)
IsLocked/unlocked-16                          6.117µ ± 18%   3.112µ ± 2%  -49.12% (p=0.000 n=10)
geomean                                       11.33µ         7.844µ       -30.79%

                                           │   old.txt    │               new.txt                │
                                           │     B/op     │     B/op      vs base                │
Search/user_attribute-16                     2.547Ki ± 0%   2.445Ki ± 0%   -3.99% (p=0.000 n=10)
Search/associated_object_with_attribute-16   2.203Ki ± 0%   2.305Ki ± 0%   +4.61% (p=0.000 n=10)
IsLocked/locked-16                           1.455Ki ± 0%   1.250Ki ± 0%  -14.09% (p=0.000 n=10)
IsLocked/unlocked-16                           945.0 ± 0%     840.0 ± 0%  -11.11% (p=0.000 n=10)
geomean                                      1.657Ki        1.550Ki        -6.42%

                                           │  old.txt   │              new.txt               │
                                           │ allocs/op  │ allocs/op   vs base                │
Search/user_attribute-16                     52.00 ± 0%   50.00 ± 0%   -3.85% (p=0.000 n=10)
Search/associated_object_with_attribute-16   46.00 ± 0%   47.00 ± 0%   +2.17% (p=0.000 n=10)
IsLocked/locked-16                           33.00 ± 0%   29.00 ± 0%  -12.12% (p=0.000 n=10)
IsLocked/unlocked-16                         20.00 ± 0%   18.00 ± 0%  -10.00% (p=0.000 n=10)
geomean                                      35.45        33.28        -6.11%
```

Closes #3926.

Signed-off-by: Andrey Butusov <andrey@nspcc.io>
@End-rey End-rey force-pushed the associated-object-field-format branch from 789c655 to bec2d00 Compare April 30, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reconsider associated object field format in metabase

2 participants