Skip to content

Commit 349afbb

Browse files
committed
Improved filterBlocksByRingSharding() logic
Signed-off-by: Marco Pracucci <[email protected]>
1 parent 68cacc1 commit 349afbb

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

pkg/storegateway/sharding_strategy.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,20 @@ func filterBlocksByRingSharding(r ring.ReadRing, instanceAddr string, metas map[
129129
for blockID := range metas {
130130
key := cortex_tsdb.HashBlockID(blockID)
131131

132-
// A block needs to be always loaded if is owned by the store-gateway itself.
132+
// Check if the block is owned by the store-gateway
133133
set, err := r.Get(key, BlocksOwnerSync, bufDescs, bufHosts, bufZones)
134-
if err != nil {
135-
level.Warn(logger).Log("msg", "excluded block because failed to get replication set", "block", blockID.String(), "err", err)
136134

137-
// Skip the block.
138-
synced.WithLabelValues(shardExcludedMeta).Inc()
139-
delete(metas, blockID)
135+
// If an error occurs while checking the ring, we keep the previously loaded blocks.
136+
if err != nil {
137+
if _, ok := loaded[blockID]; ok {
138+
level.Warn(logger).Log("msg", "failed to check block owner but block is kept because was previously loaded", "block", blockID.String(), "err", err)
139+
} else {
140+
level.Warn(logger).Log("msg", "failed to check block owner and block has been excluded because was not previously loaded", "block", blockID.String(), "err", err)
141+
142+
// Skip the block.
143+
synced.WithLabelValues(shardExcludedMeta).Inc()
144+
delete(metas, blockID)
145+
}
140146

141147
continue
142148
}

0 commit comments

Comments
 (0)