Skip to content

Commit

Permalink
fix: concurrent map writes to temporalityMap (#5432)
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanthccv authored Jul 10, 2024
1 parent 3b2a811 commit 831de18
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/query-service/app/http_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ type APIHandler struct {
// querying the v4 table on low cardinal temporality column
// should be fast but we can still avoid the query if we have the data in memory
temporalityMap map[string]map[v3.Temporality]bool
temporalityMux sync.Mutex

maxIdleConns int
maxOpenConns int
Expand Down Expand Up @@ -455,6 +456,9 @@ func (aH *APIHandler) getRule(w http.ResponseWriter, r *http.Request) {
// populateTemporality adds the temporality to the query if it is not present
func (aH *APIHandler) populateTemporality(ctx context.Context, qp *v3.QueryRangeParamsV3) error {

aH.temporalityMux.Lock()
defer aH.temporalityMux.Unlock()

missingTemporality := make([]string, 0)
metricNameToTemporality := make(map[string]map[v3.Temporality]bool)
if qp.CompositeQuery != nil && len(qp.CompositeQuery.BuilderQueries) > 0 {
Expand Down

0 comments on commit 831de18

Please sign in to comment.