Repository navigation
Fall back when a topic loses every leader, count the drop, and refresh again - #96
Merged
Merged
Conversation
… that names none.
terryxsun
approved these changes
Oct 2, 2026
stephclay
approved these changes
Oct 2, 2026
This was referenced Oct 8, 2026
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.
Summary
Port of #95 onto main.
#88 falls back only when some other partition of the topic still has a leader. If every named leader for a topic is excluded in one refresh, Candidates still returns nil and ProduceSync fails the whole batch, including healthy topics. This change treats that topic as known and hashes it onto a live agent. A topic Metadata has never returned, and a topic-level error, stay unknown so they still trigger an on-demand refresh. A partition Metadata reported with no leader (Leader below 0) does not hash and is not counted as a drop. It fails, and the existing nil-candidate path refreshes.
A refresh that excludes a leader increments warpstream_agentpool_leader_dropped_total (once per excluded leader, including the constructor) and logs the count plus the first excluded leader (first_topic, first_partition, first_node_id). The background refresh nudges another fetch. After a periodic tick that follow-up starts at once; later repeats wait out OnDemandMetadataRefreshInterval (default 1s). The constructor counts and logs, and does not nudge. Produce does not wait. AgentPool.Refresh stays ([]int32, error). The drop details are on the unexported refresh.
This also covers the broker/topic mismatch RequestCachedMetadata can return, described upstream in twmb/franz-go#1481: a leader id present in Topics but missing from that same response's Brokers now hashes onto a live agent instead of failing the batch.
Also addresses the #88 review comment on the benchmark sink: the comment now describes the benchmark's own allocation count, not how AgentPool.Refresh uses the result.
Left for follow-up PRs, still part of the leader-map fallback: