Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Empty metdata response when upgrading to v1.20.0 kadm/v1.17.0Β #1142

@countableSet

Description

@countableSet

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

Image

franz-go/pkg/kgo/client.go

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

Image

franz-go/pkg/kgo/client.go

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

Image

franz-go/pkg/kgo/client.go

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.

_, _, err := cl.fetchMetadataForTopics(ctx, false, needed, intoMapped)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions