Skip to content

policer: balance local shard data - #4170

Open
End-rey wants to merge 1 commit into
masterfrom
shard-data-balancing
Open

policer: balance local shard data#4170
End-rey wants to merge 1 commit into
masterfrom
shard-data-balancing

Conversation

@End-rey

@End-rey End-rey commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Closes #4147.

One edge case to consider: a copy marked with GarbageMarkRedundant is still visible to Exists, but remains queued for GC. If shard topology changes and this shard becomes the HRW-preferred target again before GC runs, relocation sees that the object already exists and does not clear the redundant mark. GC may then remove the current target copy.

Should we handle this by adding a targeted operation similar to ClearRedundantMark for the selected target shard, without reviving regular GC or tombstone marks?

@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.90698% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 31.14%. Comparing base (b513ecb) to head (bed00fb).

Files with missing lines Patch % Lines
pkg/local_object_storage/engine/optimize.go 84.48% 9 Missing ⚠️
pkg/metrics/state.go 0.00% 4 Missing ⚠️
pkg/services/policer/check.go 76.92% 3 Missing ⚠️
cmd/neofs-node/control.go 0.00% 1 Missing ⚠️
pkg/services/policer/ec.go 88.88% 1 Missing ⚠️
pkg/services/policer/policer.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4170      +/-   ##
==========================================
+ Coverage   31.03%   31.14%   +0.10%     
==========================================
  Files         673      674       +1     
  Lines       40673    40716      +43     
==========================================
+ Hits        12623    12681      +58     
+ Misses      28050    28035      -15     

☔ View full report in Codecov by Harness.
📢 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.

@roman-khimov
roman-khimov requested a balanced review from Copilot September 11, 2026 13:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@roman-khimov roman-khimov left a comment

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.

If shard topology changes and this shard becomes the HRW-preferred target again before GC runs, relocation sees that the object already exists and does not clear the redundant mark. GC may then remove the current target copy.

This will be fixed by the next policer iteration. Too rare to care.

Comment thread pkg/services/policer/check.go Outdated
return
}
if moved {
p.metrics.IncPolicerObjectRelocated(isEC)

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.

Why separating EC and non-EC here? These are all physical objects.

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.

Comment thread pkg/services/policer/policer.go Outdated
ListWithCursor(context.Context, uint32, *engine.Cursor, ...string) ([]objectcore.AddressWithAttributes, *engine.Cursor, error)
Delete(context.Context, oid.Address, engine.GarbageMark) error
DeleteRedundantCopies(context.Context, oid.Address, []string) error
RelocateObject(context.Context, oid.Address, []string) (bool, 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.

It's more like OptimizeShardLocation to me. Relocate implies movement, but it's entirely optional here and in most cases this callback does nothing.

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.

Renamed.

return false, errShardNotFound
}

shards := e.sortedShards(addr.Object())

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.

Thought of avoiding getting this list again, but looks like it requires ListWithCursor changes. Shouldn't be performance-critical. At the same time we can optimize the scheme by checking placement in ListWithCursor and returning shard list only if there is something to fix there.

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.

Considered it, but that would sort shards for every listed object, including remotely redundant ones. Current code sorts only objects policer keeps locally and skips the target existence check for objects already listed only on their preferred shard.

return false, apistatus.ObjectNotFound{}
}

err = e.putToShard(target, addr, obj, nil)

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.

Do we have any log message for 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.

Done.

continue
}

if err = source.MarkGarbage(addr.Container(), []oid.ID{addr.Object()}, GarbageMarkRedundant); err != nil {

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.

Log?

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.

@End-rey
End-rey force-pushed the shard-data-balancing branch 2 times, most recently from 62e9439 to bed00fb Compare September 12, 2026 11:46
Relocate objects to their HRW-preferred local shard during policer scans. Mark
old copies redundant only after a successful writing to the target.

Closes #4147.

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.

Shard data balancing

3 participants