Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ring: add GetWithOptions method to adjust per call behavior #632

Merged
merged 6 commits into from
Jan 28, 2025

Conversation

56quarters
Copy link
Contributor

@56quarters 56quarters commented Jan 3, 2025

What this PR does:

This change adds a new method that accepts 0 or more Option instances that modify the behavior of the call. These options can (currently) be used to adjust the replication factor for a particular key or use buffers to avoid excessive allocation.

The most notable changes are in the Ring.findInstancesForKey method which is the core of the Ring.Get method. Instead of keeping track of distinct zones and assuming that only a single instance per zone would ever be returned, we keep a map of the number of instances found in each zone.

Which issue(s) this PR fixes:

Part of grafana/mimir#9944

Previous attempt #620

Checklist

  • Tests updated
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

ring/ring.go Show resolved Hide resolved
@56quarters 56quarters force-pushed the 56quarters/sg-replication branch 2 times, most recently from 35571f9 to e17f2cc Compare January 3, 2025 19:58
ring/ring_test.go Outdated Show resolved Hide resolved
ring/ring.go Outdated Show resolved Hide resolved
@56quarters 56quarters force-pushed the 56quarters/sg-replication branch from 6c1dec6 to 7b887a7 Compare January 6, 2025 14:59
Copy link
Contributor

@dimitarvdimitrov dimitarvdimitrov left a comment

Choose a reason for hiding this comment

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

only reviewed the prod changes so far

ring/replication_strategy.go Show resolved Hide resolved
ring/ring.go Show resolved Hide resolved
This change adds a new method that accepts 0 or more `Option` instances
that modify the behavior of the call. These options can (currently) be
used to adjust the replication factor for a particular key or use buffers
to avoid excessive allocation.

The most notable changes are in the `Ring.findInstancesForKey` method
which is the core of the `Ring.Get` method. Instead of keeping track
of distinct zones and assuming that only a single instance per zone
would ever be returned, we keep a map of the number of instances
found in each zone.

Part of grafana/mimir#9944
Signed-off-by: Nick Pillitteri <[email protected]>
@56quarters 56quarters force-pushed the 56quarters/sg-replication branch from 7b887a7 to bf94082 Compare January 13, 2025 16:58
Copy link
Contributor

@dimitarvdimitrov dimitarvdimitrov left a comment

Choose a reason for hiding this comment

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

prod changes look good, I left some comments on the tests

ring/ring_test.go Outdated Show resolved Hide resolved
ring/ring_test.go Show resolved Hide resolved
ring/token_range_test.go Show resolved Hide resolved
Signed-off-by: Nick Pillitteri <[email protected]>
This change uses the configured replication factor for the ring to determine
the number of zones that should exist when zone-aware replication is enabled

Signed-off-by: Nick Pillitteri <[email protected]>
Copy link
Contributor

@dimitarvdimitrov dimitarvdimitrov left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

Signed-off-by: Nick Pillitteri <[email protected]>
@56quarters 56quarters merged commit 104df19 into main Jan 28, 2025
5 checks passed
@56quarters 56quarters deleted the 56quarters/sg-replication branch January 28, 2025 19:39
56quarters added a commit to grafana/mimir that referenced this pull request Jan 28, 2025
Pulls in grafana/dskit#632

Signed-off-by: Nick Pillitteri <[email protected]>
56quarters added a commit to grafana/mimir that referenced this pull request Jan 28, 2025
Pulls in grafana/dskit#632

Signed-off-by: Nick Pillitteri <[email protected]>
56quarters added a commit to grafana/mimir that referenced this pull request Jan 30, 2025
* Allow expanded replication set of TSDB blocks on store-gateways

This change adds a tenant-specific setting to allow a subset of TSDB
blocks to be replicated to more than the configured replication factor
(three by default) on store-gateways.

* mimir-microservices-mode: Use default store-gateway replication factor

* Add grace period to expanded replication time range

Much like how block uploads have a grace period, add a grace period
when querying with expanded replication to make sure store-gateways
have enough time to load blocks before they are queried.

Signed-off-by: Nick Pillitteri <[email protected]>

* Code review feedback

Signed-off-by: Nick Pillitteri <[email protected]>

* Apply grace period to max time _and_ upload time.

Signed-off-by: Nick Pillitteri <[email protected]>

* Don't check upload time in expanded replication

Upload time is checked (and blocks within a grace period are ignored)
by the query consistency check.

Signed-off-by: Nick Pillitteri <[email protected]>

* Code review changes

Apply grace period to sync instead of querying

Signed-off-by: Nick Pillitteri <[email protected]>

* Rename feature to "dynamic_replication"

Signed-off-by: Nick Pillitteri <[email protected]>

* Fix comment about how grace period works

Signed-off-by: Nick Pillitteri <[email protected]>

* Update comments about dynamic replication grace period

Signed-off-by: Nick Pillitteri <[email protected]>

* Update to latest dskit commit

Signed-off-by: Nick Pillitteri <[email protected]>

* Switch to latest dskit main

Pulls in grafana/dskit#632

Signed-off-by: Nick Pillitteri <[email protected]>

* Code review changes

Signed-off-by: Nick Pillitteri <[email protected]>

---------

Signed-off-by: Nick Pillitteri <[email protected]>
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.

2 participants