Commit 6c73af5
authored
scrape: timeout WriteRaw, drop sp.mtx before waiting on loops (#6361)
The per-target scrape loop bounded only the HTTP scrape with
scrape_timeout; the subsequent store.WriteRaw call ran under the bare
scrapeCtx with no deadline. When write latency spiked, each iteration
blocked indefinitely inside WriteRaw and the target appeared to stop
scraping (time.Ticker doesn't accumulate, so only one make-up scrape
fires after the call returns). WriteRaw now runs under
context.WithTimeout(scrapeCtx, scrape_timeout) so a slow store fails the
scrape and the next interval fires on time.
scrapePool.stop() and reload() also held sp.mtx across wg.Wait() for old
loops to terminate. A loop wedged inside WriteRaw would therefore block
sp.mtx, and — via Manager.ApplyConfig / Stop holding m.mtxScrape — block
the manager's Run loop from draining new target sets, freezing every
pool. Both methods now snapshot the loops under sp.mtx, release the
lock, and wait on goroutines outside it, matching the pattern already
used by sync().1 parent 470ff04 commit 6c73af5
1 file changed
Lines changed: 34 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
145 | 147 | | |
146 | | - | |
147 | | - | |
| 148 | + | |
148 | 149 | | |
149 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
150 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
151 | 159 | | |
152 | 160 | | |
153 | 161 | | |
154 | 162 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | 163 | | |
159 | 164 | | |
160 | 165 | | |
| |||
166 | 171 | | |
167 | 172 | | |
168 | 173 | | |
169 | | - | |
170 | 174 | | |
171 | 175 | | |
172 | 176 | | |
| |||
177 | 181 | | |
178 | 182 | | |
179 | 183 | | |
180 | | - | |
181 | 184 | | |
182 | 185 | | |
183 | 186 | | |
184 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
185 | 194 | | |
186 | 195 | | |
187 | 196 | | |
188 | 197 | | |
189 | 198 | | |
190 | 199 | | |
191 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
192 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
193 | 208 | | |
194 | 209 | | |
195 | 210 | | |
196 | 211 | | |
197 | 212 | | |
198 | | - | |
199 | | - | |
200 | | - | |
| 213 | + | |
201 | 214 | | |
202 | 215 | | |
203 | 216 | | |
| |||
470 | 483 | | |
471 | 484 | | |
472 | 485 | | |
473 | | - | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
474 | 492 | | |
475 | 493 | | |
476 | 494 | | |
| |||
509 | 527 | | |
510 | 528 | | |
511 | 529 | | |
512 | | - | |
| 530 | + | |
513 | 531 | | |
514 | 532 | | |
515 | 533 | | |
| |||
586 | 604 | | |
587 | 605 | | |
588 | 606 | | |
589 | | - | |
| 607 | + | |
590 | 608 | | |
591 | 609 | | |
592 | 610 | | |
| |||
0 commit comments