Commit dfaef99
🪞 9757 - Avoid pending queue wedge if tracer flare is generated multiple times (#9840)
* Avoid pending queue wedge if tracer flare is generated multiple times
In DumpDrain, the collectTraces method replaces the 'data' field
with an empty ArrayList, but at the same time, it does not also
reset the 'index' field. If another dump is performed later, this
leads the get method reaching the 'return null' statement, and
as the comment states, this can (and does) break the queue.
This change does a few things:
- Resets the index in collectTraces when the data field is replaced
(and marks the index field as volatile). This should prevent the
above situation from happening.
- In case the situation still happens, a stand-in CommandElement
is returned to avoid returning null. A warning message is also logged.
- The existing "testing tracer flare dump with multiple traces"
test case is expanded to exercise problem.
Here is an example stack trace when the hang happens:
"dd-trace-monitor" #38 daemon prio=5 os_prio=31 tid=0x0000000110e6e000 nid=0x7617 runnable [0x0000000171032000]
java.lang.Thread.State: RUNNABLE
at org.jctools.queues.MpscBlockingConsumerArrayQueue.spinWaitForElement(MpscBlockingConsumerArrayQueue.java:634)
at org.jctools.queues.MpscBlockingConsumerArrayQueue.parkUntilNext(MpscBlockingConsumerArrayQueue.java:566)
at org.jctools.queues.MpscBlockingConsumerArrayQueue.take(MpscBlockingConsumerArrayQueue.java:482)
at datadog.trace.core.PendingTraceBuffer$DelayingPendingTraceBuffer$Worker.run(PendingTraceBuffer.java:317)
at java.lang.Thread.run(Thread.java:750)
* Use SEND_TELEMETRY for DumpDrain's index out of bounds warning log
---------
Co-authored-by: DJ Gregor <dj@gregor.com>1 parent 1cfa708 commit dfaef99
File tree
2 files changed
+56
-16
lines changed- dd-trace-core/src
- main/java/datadog/trace/core
- test/groovy/datadog/trace/core
2 files changed
+56
-16
lines changedLines changed: 14 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| 62 | + | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| |||
145 | 147 | | |
146 | 148 | | |
147 | 149 | | |
| 150 | + | |
148 | 151 | | |
149 | 152 | | |
150 | 153 | | |
| |||
154 | 157 | | |
155 | 158 | | |
156 | 159 | | |
157 | | - | |
| 160 | + | |
158 | 161 | | |
159 | 162 | | |
160 | 163 | | |
| |||
166 | 169 | | |
167 | 170 | | |
168 | 171 | | |
169 | | - | |
170 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
171 | 181 | | |
172 | 182 | | |
173 | 183 | | |
174 | 184 | | |
175 | 185 | | |
| 186 | + | |
176 | 187 | | |
177 | 188 | | |
178 | 189 | | |
| |||
Lines changed: 42 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
460 | 460 | | |
461 | 461 | | |
462 | 462 | | |
463 | | - | |
| 463 | + | |
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
467 | | - | |
| 467 | + | |
468 | 468 | | |
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
472 | 472 | | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
482 | 499 | | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
483 | 508 | | |
484 | 509 | | |
485 | | - | |
486 | | - | |
| 510 | + | |
| 511 | + | |
487 | 512 | | |
488 | 513 | | |
489 | 514 | | |
490 | 515 | | |
491 | 516 | | |
492 | 517 | | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
493 | 522 | | |
494 | 523 | | |
495 | 524 | | |
| |||
0 commit comments