Must be called with lock.
()
| 240 | |
| 241 | // Must be called with lock. |
| 242 | func (w *querierWorker) resetConcurrency() { |
| 243 | totalConcurrency := 0 |
| 244 | index := 0 |
| 245 | |
| 246 | for _, m := range w.managers { |
| 247 | concurrency := 0 |
| 248 | |
| 249 | if w.cfg.MatchMaxConcurrency { |
| 250 | concurrency = w.cfg.MaxConcurrentRequests / len(w.managers) |
| 251 | |
| 252 | // If max concurrency does not evenly divide into our frontends a subset will be chosen |
| 253 | // to receive an extra connection. Frontend addresses were shuffled above so this will be a |
| 254 | // random selection of frontends. |
| 255 | if index < w.cfg.MaxConcurrentRequests%len(w.managers) { |
| 256 | level.Warn(w.log).Log("msg", "max concurrency is not evenly divisible across targets, adding an extra connection", "addr", m.address) |
| 257 | concurrency++ |
| 258 | } |
| 259 | } else { |
| 260 | concurrency = w.cfg.Parallelism |
| 261 | } |
| 262 | |
| 263 | // If concurrency is 0 then MaxConcurrentRequests is less than the total number of |
| 264 | // frontends/schedulers. In order to prevent accidentally starving a frontend or scheduler we are just going to |
| 265 | // always connect once to every target. This is dangerous b/c we may start exceeding PromQL |
| 266 | // max concurrency. |
| 267 | if concurrency == 0 { |
| 268 | concurrency = 1 |
| 269 | } |
| 270 | |
| 271 | totalConcurrency += concurrency |
| 272 | m.concurrency(concurrency) |
| 273 | index++ |
| 274 | } |
| 275 | |
| 276 | if totalConcurrency > w.cfg.MaxConcurrentRequests { |
| 277 | level.Warn(w.log).Log("msg", "total worker concurrency is greater than promql max concurrency. Queries may be queued in the querier which reduces QOS") |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | func (w *querierWorker) connect(address string) (*grpc.ClientConn, error) { |
| 282 | // Because we only use single long-running method, it doesn't make sense to inject user ID, send over tracing or add metrics. |
no test coverage detected