-
-
Notifications
You must be signed in to change notification settings - Fork 252
Description
After upgrading to v1.20.0 and kadm/v1.17.0 metadata requests now return empty results. I think this might have something to do with the metadata cache changes.
Simple poc repo if needed; https://github.com/countableSet/franz-go-1142
I tracked it to this commit 30ed0f3 that now uses method RequestCachedMetadata
fn := func() (*kmsg.MetadataResponse, error) {
return cl.cl.RequestCachedMetadata(ctx, req, 0)
}In the case of no topics provided to metadata request
if noTopics {
req.Topics = []kmsg.MetadataRequestTopic{}
}fetchMappedMetadata within the client the request metadata cache will have an empty slice of topics
Lines 2680 to 2688 in 5e6bc01
| func (cl *Client) fetchMappedMetadata(ctx context.Context, topics []string, useCache bool, limit time.Duration) (map[string]mappedMetadataTopic, error) { | |
| var intoMapped map[string]mappedMetadataTopic | |
| needed := topics | |
| if useCache { | |
| intoMapped, needed = cl.fetchCachedMappedMetadata(limit, topics...) | |
| if len(needed) == 0 { | |
| return intoMapped, nil | |
| } | |
| } |
and fetchCachedMappedMetadata will return return nil, ts
Lines 2652 to 2657 in 5e6bc01
| func (cl *Client) fetchCachedMappedMetadata(limit time.Duration, ts ...string) (map[string]mappedMetadataTopic, []string) { | |
| cl.mappedMetaMu.Lock() | |
| defer cl.mappedMetaMu.Unlock() | |
| if cl.mappedMeta == nil { | |
| return nil, ts | |
| } |
this causes len(needed) == 0 and intoMapped == nil
Lines 2684 to 2687 in 5e6bc01
| intoMapped, needed = cl.fetchCachedMappedMetadata(limit, topics...) | |
| if len(needed) == 0 { | |
| return intoMapped, nil | |
| } |
Thus always returning nil metadata and not reaching the actual fetch request here.
Line 2693 in 5e6bc01
| _, _, err := cl.fetchMetadataForTopics(ctx, false, needed, intoMapped) |