Skip to content
Open
Changes from 1 commit
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 util/otelmetrics/query_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,13 @@ func (qc *QueryCache) Get(ctx context.Context, metricName string) ([]MetricResul
// Fetch without holding any lock
entry := qc.fetchFiltered(ctx, metricName)

// Store and signal waiters
// Store and signal waiters.
// Do not cache empty successful results; a transient miss would poison
// all later lookups for this metric within the same test binary run.
qc.mu.Lock()
qc.filtered[metricName] = entry
if len(entry.results) > 0 || entry.err != nil {
Comment thread
olowosulu marked this conversation as resolved.
qc.filtered[metricName] = entry
Comment thread
olowosulu marked this conversation as resolved.
}
delete(qc.inflight, metricName)
qc.mu.Unlock()
close(ch)
Expand Down Expand Up @@ -249,8 +253,12 @@ func (qc *QueryCache) GetUnfiltered(ctx context.Context, metricName string) ([]M
results, queryErr := qc.client.Query(ctx, metricName)
entry := cacheEntry{results: results, err: queryErr}

// Do not cache empty successful results; a transient miss would poison
// all later lookups for this metric within the same test binary run.
qc.mu.Lock()
qc.unfiltered[metricName] = entry
if len(entry.results) > 0 || entry.err != nil {
qc.unfiltered[metricName] = entry
}
qc.mu.Unlock()

return entry.results, entry.err
Expand Down
Loading