fix(limits): Set ready when all partitions ready - #18092
Merged
Merged
Conversation
grobinson-grafana
force-pushed
the
partition-aware-readiness
branch
3 times, most recently
from
June 18, 2025 13:51
e2c8706 to
f5a3e24
Compare
This commit moves the partition readiness check after the service and lifecycler readiness checks. It does this because the partition readiness check cannot pass until the consumer is running, and the consumer.Run() goroutine is not started until running() is called. That means it makes sense to check the service state and the lifecycler before checking the partitions.
grobinson-grafana
force-pushed
the
partition-aware-readiness
branch
from
June 18, 2025 13:52
f5a3e24 to
6e0276f
Compare
This commit fixes a race condition where the maximum attempts is never satisifed. This race condition comes about as two (or more) goroutines can load and increment the atomic concurrently, which would cause the next Load() to load a value greater than the maximum number of attempts, breaking the equality check.
grobinson-grafana
force-pushed
the
partition-aware-readiness
branch
from
June 18, 2025 14:15
60ee2da to
e962ba3
Compare
This commit fixes the race condition that exists between two (or more) goroutines concurrently executing CheckReady. What can happen is both goroutines call Load at the same time, do the check, and then increment the number of attempts without using check-and-set. This allowed the number of attempts to exceed the maximum number of attempts.
grobinson-grafana
force-pushed
the
partition-aware-readiness
branch
from
June 18, 2025 14:15
e962ba3 to
a6c2ffa
Compare
grobinson-grafana
force-pushed
the
partition-aware-readiness
branch
from
June 18, 2025 15:44
414fff0 to
4a8dabf
Compare
grobinson-grafana
force-pushed
the
partition-aware-readiness
branch
from
June 18, 2025 15:44
4a8dabf to
865bc62
Compare
grobinson-grafana
force-pushed
the
partition-aware-readiness
branch
from
June 18, 2025 15:46
c12dffd to
c83e653
Compare
| // The maximum amount of time to wait to join the consumer group and be | ||
| // assigned some partitions before giving up and going ready in | ||
| // [Service.CheckReady]. | ||
| partitionReadinessWaitAssignPeriod = 30 * time.Second |
Contributor
There was a problem hiding this comment.
I changed this so now the time that we wait is independent of:
- The readiness check interval
- The number of clients calling
/ready
grobinson-grafana
approved these changes
Jun 20, 2025
This was referenced Nov 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
This pull request makes the ingest-limits readiness handler to consider partition state before signaling ready. I.e. the service is considered to be ready and consume traffic when the following conditions apply:
Which issue(s) this PR fixes:
Fixes #grafana/loki-private/issues/1722
Special notes for your reviewer:
Checklist
CONTRIBUTING.mdguide (required)featPRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.docs/sources/setup/upgrade/_index.mddeprecated-config.yamlanddeleted-config.yamlfiles respectively in thetools/deprecated-config-checkerdirectory. Example PR