Avoid that the reporter blocks server shutdown#554
Avoid that the reporter blocks server shutdown#554felixbarny merged 2 commits intoelastic:masterfrom
Conversation
…ailable slots in the ring buffer
Codecov Report
@@ Coverage Diff @@
## master #554 +/- ##
============================================
- Coverage 65.25% 63.11% -2.15%
Complexity 68 68
============================================
Files 180 180
Lines 7209 6815 -394
Branches 863 780 -83
============================================
- Hits 4704 4301 -403
+ Misses 2251 2249 -2
- Partials 254 265 +11
Continue to review full report at Codecov.
|
|
On shutdown, the reporter tries to publish a shutdown event and then calls the Then it wakes up the Handler thread, which may try to flush current buffered serialized data, but not flush all events in buffer: This also changes the state of the Handler so that it shouldn't continue trying to send events, but in any case, this thread is a daemon thread, so it shouldn't prevent shutdown. The only blocking thing here seems to be the What am I missing here? |
That's correct. I think with this change we're all good. |
This only happens after the APM Server is not available for a while. In that case, the reporter queue fills up and can never really drain because the reporter blocks its thread to throttle APM Server connection retries. On shutdown, the reporter tries to flush by registering a flush event. The registration blocks until a new slot in the ring buffer becomes available. But due to the throttling only once every 36 seconds, an event is picked up from the ring buffer. So a shutdown takes around 512 * 36 seconds.