Skip to content

Storage shard id generation#3889

Open
End-rey wants to merge 2 commits intomasterfrom
storage-shard-id-generation
Open

Storage shard id generation#3889
End-rey wants to merge 2 commits intomasterfrom
storage-shard-id-generation

Conversation

@End-rey
Copy link
Copy Markdown
Contributor

@End-rey End-rey commented Mar 20, 2026

Closes #3859.

Two design points changed in this PR and I would like extra attention there:

  • shard.New() now calls ResolveID() eagerly, so shard ID is known before Init().
  • fstree/blobstor now works through Init(shardID), and the same ID is then propagated to metabase and write-cache.

This is consistent with the earlier discussion, but these changes move some responsibility across New/Init boundaries, so I would like to double-check that the lifecycle still looks right.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 20, 2026

Codecov Report

❌ Patch coverage is 40.61303% with 155 lines in your changes missing coverage. Please review.
✅ Project coverage is 26.77%. Comparing base (60d685f) to head (4c4a082).

Files with missing lines Patch % Lines
pkg/local_object_storage/blobstor/common/id.go 40.62% 17 Missing and 2 partials ⚠️
pkg/local_object_storage/metabase/shard_id.go 13.63% 19 Missing ⚠️
pkg/local_object_storage/shard/control.go 52.50% 10 Missing and 9 partials ⚠️
...kg/local_object_storage/blobstor/fstree/control.go 58.97% 13 Missing and 3 partials ⚠️
pkg/services/control/server/helpers.go 0.00% 11 Missing ⚠️
cmd/neofs-lancet/internal/meta/resync.go 0.00% 8 Missing ⚠️
pkg/local_object_storage/blobstor/fstree/fstree.go 12.50% 7 Missing ⚠️
pkg/local_object_storage/metabase/control.go 44.44% 4 Missing and 1 partial ⚠️
pkg/local_object_storage/engine/shards.go 80.95% 3 Missing and 1 partial ⚠️
...cal_object_storage/internal/storagetest/storage.go 0.00% 4 Missing ⚠️
... and 25 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3889      +/-   ##
==========================================
- Coverage   26.78%   26.77%   -0.02%     
==========================================
  Files         677      677              
  Lines       44616    44665      +49     
==========================================
+ Hits        11952    11957       +5     
- Misses      31553    31593      +40     
- Partials     1111     1115       +4     

☔ 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.

@End-rey End-rey force-pushed the storage-shard-id-generation branch 3 times, most recently from ec034b9 to 2773eac Compare March 25, 2026 20:16
Copy link
Copy Markdown
Member

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

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

Much better now.

}

// DecodeString decodes base58 string into ID.
func DecodeString(s string) (ID, error) {
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.

DecodeIDString, this package has other things besides ID, so common.DecodeString can mean anything.

}

// NewFromBytes constructs ID from fixed-size raw bytes.
func NewFromBytes(v []byte) (ID, error) {
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.

NewIDFromBytes as well.

s := cons(t)
require.NoError(t, s.Open(false))
require.NoError(t, s.Init())
require.NoError(t, s.Init(common.ID{}))
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.

I'm looking at how many changes there are like this and maybe some InitIdentified(), InitAsSecondary() or InitWithID() would be helpful. Most of the time ID is zero. This however will affect blobstor interface. Opinions are welcome, current code works too, just the necessity of passing this common.ID{} around that bugs me.

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.

I would make this change only for blobstor, since it’s the only one whose code might encounter a situation where the ID doesn’t need to be specified - it can retrieve or generate it on its own. For metabase and writecache, the current API is only used with IDs, and they’re empty only in tests because it’s not that important there.

@End-rey End-rey force-pushed the storage-shard-id-generation branch from 2773eac to 5aa2ad9 Compare March 27, 2026 15:53
Extract shard ID into `pkg/local_object_storage/blobstor/common` and switch
internal usages to `common.ID`. This moves the type closer to its storage domain
and avoids base58-oriented handling in internal storage.

Signed-off-by: Andrey Butusov <andrey@nspcc.io>
@End-rey End-rey force-pushed the storage-shard-id-generation branch from 5aa2ad9 to 4c4a082 Compare March 27, 2026 16:42
Make fstree/blobstor the canonical shard ID source and propagate the resulting
ID to metabase and write-cache during shard initialization.
Align shard and engine initialization with this flow.
Store fstree subtype in the descriptor to distinguish blobstor from
write-cache in recovery scenarios, with blobstor as the default subtype.

Closes #3859.

Signed-off-by: Andrey Butusov <andrey@nspcc.io>
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.

Improve shard id generation/storage

2 participants