Skip to content

Commit 78d3c44

Browse files
authored
fix(blooms): Fix check for skipping most recent data when filtering blooms (#15300)
After changing the default of `-bloom-build.planner.min-table-offset` from `1` (yesterday) to `0` (today), we noticed that the bloom gateways reported a very high percentage of missing series in blocks. This is because the gateway received filter requests for today's block, but the requested series is too new and has not been added to the bloom block yet. In the bloom querier on the index gateway there is a condition under which requests to the bloom gateway are skipped, because the blooms are likely not available yet. This PR changes this condition to correctly take the min-table-offset as well as the planning-interval into account. Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
1 parent 079779e commit 78d3c44

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

‎pkg/bloomgateway/querier.go

+24-26
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ func newQuerierMetrics(registerer prometheus.Registerer, namespace, subsystem st
7272
}
7373

7474
type QuerierConfig struct {
75-
// MinTableOffset is derived from the compactor's MinTableOffset
76-
MinTableOffset int
75+
BuildInterval time.Duration
76+
BuildTableOffset int
7777
}
7878

7979
// BloomQuerier is a store-level abstraction on top of Client
@@ -119,30 +119,28 @@ func (bq *BloomQuerier) FilterChunkRefs(ctx context.Context, tenant string, from
119119
preFilterSeries := len(grouped)
120120

121121
// Do not attempt to filter chunks for which there are no blooms
122-
if bq.cfg.MinTableOffset > 0 {
123-
minAge := truncateDay(model.Now()).Add(-1 * config.ObjectStorageIndexRequiredPeriod * time.Duration(bq.cfg.MinTableOffset-1))
124-
if through.After(minAge) {
125-
level.Debug(logger).Log(
126-
"msg", "skip too recent chunks",
127-
"tenant", tenant,
128-
"from", from.Time(),
129-
"through", through.Time(),
130-
"responses", 0,
131-
"preFilterChunks", preFilterChunks,
132-
"postFilterChunks", preFilterChunks,
133-
"filteredChunks", 0,
134-
"preFilterSeries", preFilterSeries,
135-
"postFilterSeries", preFilterSeries,
136-
"filteredSeries", 0,
137-
)
138-
139-
bq.metrics.chunksTotal.Add(float64(preFilterChunks))
140-
bq.metrics.chunksFiltered.Add(0)
141-
bq.metrics.seriesTotal.Add(float64(preFilterSeries))
142-
bq.metrics.seriesFiltered.Add(0)
143-
144-
return chunkRefs, false, nil
145-
}
122+
minAge := model.Now().Add(-1 * (config.ObjectStorageIndexRequiredPeriod*time.Duration(bq.cfg.BuildTableOffset) + 2*bq.cfg.BuildInterval))
123+
if through.After(minAge) {
124+
level.Info(logger).Log(
125+
"msg", "skip too recent chunks",
126+
"tenant", tenant,
127+
"from", from.Time(),
128+
"through", through.Time(),
129+
"responses", 0,
130+
"preFilterChunks", preFilterChunks,
131+
"postFilterChunks", preFilterChunks,
132+
"filteredChunks", 0,
133+
"preFilterSeries", preFilterSeries,
134+
"postFilterSeries", preFilterSeries,
135+
"filteredSeries", 0,
136+
)
137+
138+
bq.metrics.chunksTotal.Add(float64(preFilterChunks))
139+
bq.metrics.chunksFiltered.Add(0)
140+
bq.metrics.seriesTotal.Add(float64(preFilterSeries))
141+
bq.metrics.seriesFiltered.Add(0)
142+
143+
return chunkRefs, false, nil
146144
}
147145

148146
var skippedGrps [][]*logproto.GroupedChunkRefs

‎pkg/loki/modules.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,8 @@ func (t *Loki) initIndexGateway() (services.Service, error) {
15421542
}
15431543
resolver := bloomgateway.NewBlockResolver(t.BloomStore, logger)
15441544
querierCfg := bloomgateway.QuerierConfig{
1545-
MinTableOffset: t.Cfg.BloomBuild.Planner.MinTableOffset,
1545+
BuildTableOffset: t.Cfg.BloomBuild.Planner.MinTableOffset,
1546+
BuildInterval: t.Cfg.BloomBuild.Planner.PlanningInterval,
15461547
}
15471548
bloomQuerier = bloomgateway.NewQuerier(bloomGatewayClient, querierCfg, t.Overrides, resolver, prometheus.DefaultRegisterer, logger)
15481549
}

0 commit comments

Comments
 (0)