Skip to content

Commit c05a0e7

Browse files
grafanabotchaudum
andauthored
chore: [k212] fix(blooms): Use correct key to populate blockscache at startup (#13626)
Co-authored-by: Christian Haudum <[email protected]>
1 parent b8e16b6 commit c05a0e7

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

pkg/storage/stores/shipper/bloomshipper/cache.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,12 @@ func loadBlockDirectories(root string, logger log.Logger) (keys []string, values
100100
}
101101

102102
if ok, clean := isBlockDir(path, logger); ok {
103-
keys = append(keys, resolver.Block(ref).Addr())
103+
// the cache key must not contain the directory prefix
104+
// therefore we use the defaultKeyResolver to resolve the block's address
105+
key := defaultKeyResolver{}.Block(ref).Addr()
106+
keys = append(keys, key)
104107
values = append(values, NewBlockDirectory(ref, path))
105-
level.Debug(logger).Log("msg", "found block directory", "ref", ref, "path", path)
108+
level.Debug(logger).Log("msg", "found block directory", "path", path, "key", key)
106109
} else {
107110
level.Warn(logger).Log("msg", "skip directory entry", "err", "not a block directory containing blooms and series", "path", path)
108111
_ = clean(path)

pkg/storage/stores/shipper/bloomshipper/cache_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func Test_LoadBlocksDirIntoCache(t *testing.T) {
9999

100100
require.Equal(t, 1, len(c.entries))
101101

102-
key := filepath.Join(wd, validDir) + ".tar.gz"
102+
key := validDir + ".tar.gz" // cache key must not contain directory prefix
103103
elem, found := c.entries[key]
104104
require.True(t, found)
105105
blockDir := elem.Value.(*Entry).Value

0 commit comments

Comments
 (0)