GH-3208 Assign partitions to KafkaBinderMetrics metadata consumer to avoid 'no longer assigned' WARN flood - #3252
Open
akenra wants to merge 1 commit into
Open
GH-3208 Assign partitions to KafkaBinderMetrics metadata consumer to avoid 'no longer assigned' WARN flood#3252akenra wants to merge 1 commit into
akenra wants to merge 1 commit into
Conversation
…consumer to avoid 'no longer assigned' WARN flood Signed-off-by: akenra <37288280+akenra@users.noreply.github.com>
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.
Problem
Applications using the Kafka binder's offset-lag metrics (
spring.cloud.stream.binder.kafka.offsetgauge) get their logs flooded on kafka-clients 4.0.x-4.3.x:(with
read_uncommitted, the variant is... high watermark ...). A reproducer was attached to the issue.Root cause
The warning is emitted by kafka-clients itself in
OffsetFetcherUtils.updateSubscriptionState()whenever a LIST_OFFSETS response arrives for a partition that is not in that consumer's current assignment (introduced by KAFKA-20131; downgraded to DEBUG only in kafka-clients 4.4.0 by KAFKA-20449).KafkaBinderMetrics.findTotalTopicGroupLaguses a long-lived metadataConsumerper group that never subscribes or assigns any partitions. Every lag computation - scheduled everyoffsetLagMetricsIntervaland additionally on every gauge scrape whendefaultOffsetLagMetricsEnabled=true- callsendOffsets(), so every partition hits the "no longer assigned" path every time. For this usage it is structural, not a rebalance race.Fix
Manually assign the discovered partitions to the metadata consumer before querying offsets:
This keeps the client-side subscription state consistent with our usage so response processing takes the silent trace-level path. Computed lag values are unchanged (all existing metric-value assertions pass untouched).
Testing
assign()happens beforeendOffsets()on every computation.KafkaBinderMetricsLoggingTestsruns against an embedded broker withisolation.level=read_committed(mirroring the reporter's setup) and asserts zero such WARN events across repeated computations: it captures 8 warnings pre-fix, zero post-fix.KafkaBinderMetricsTest(13 tests),KafkaMultiBinderCustomConfigurationTests(customKafkaBinderMetricssubclass) andKafkaBinderUnitTestsall green.Resolves #3208
Follow-up ideas (out of scope here)
Consumerfrom different scheduler threads (pre-existing).AdminClient.listOffsets()/listConsumerGroupOffsets()based computation would remove per-group consumer threads entirely and decouple metrics from the app'sisolation.level.