Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(blooms): bloomshipper no longer returns empty metas on fetch #13130

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions pkg/storage/stores/shipper/bloomshipper/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ func (b *BloomClient) Stop() {
}

func (b *BloomClient) GetMetas(ctx context.Context, refs []MetaRef) ([]Meta, error) {
results := make([]Meta, len(refs))
results := make([]*Meta, len(refs))
err := concurrency.ForEachJob(ctx, len(refs), b.concurrency, func(ctx context.Context, idx int) error {
meta, err := b.GetMeta(ctx, refs[idx])
if err != nil {
Expand All @@ -395,11 +395,19 @@ func (b *BloomClient) GetMetas(ctx context.Context, refs []MetaRef) ([]Meta, err
return fmt.Errorf("failed to get meta file %s: %w", key, err)
}
level.Error(b.logger).Log("msg", "failed to get meta file", "ref", key, "err", err)
return nil
}
results[idx] = meta
results[idx] = &meta
return nil
})
return results, err

filtered := make([]Meta, 0, len(results))
for _, r := range results {
if r != nil {
filtered = append(filtered, *r)
}
}
return filtered, err
}

// GetMeta fetches the meta file for given MetaRef from object storage and
Expand Down
8 changes: 4 additions & 4 deletions pkg/storage/stores/shipper/bloomshipper/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ func TestBloomClient_GetMetas(t *testing.T) {
require.Equal(t, metas, []Meta{m1, m2})
})

t.Run("does not exist - yields empty meta", func(t *testing.T) {
ref := MetaRef{
t.Run("does not exist - skips empty meta", func(t *testing.T) {
notExist := MetaRef{
Ref: Ref{
TenantID: "tenant",
TableName: "table",
Expand All @@ -118,9 +118,9 @@ func TestBloomClient_GetMetas(t *testing.T) {
Checksum: 1234,
},
}
metas, err := c.GetMetas(ctx, []MetaRef{ref})
metas, err := c.GetMetas(ctx, []MetaRef{notExist, m1.MetaRef})
require.NoError(t, err)
require.Equal(t, metas, []Meta{{MetaRef: ref}})
require.Equal(t, metas, []Meta{m1})
})
}

Expand Down
Loading