-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid that the reporter blocks server shutdown #554
Avoid that the reporter blocks server shutdown #554
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 apm-agent-java/apm-agent-core/src/main/java/co/elastic/apm/agent/report/ApmServerReporter.java Line 221 in 24424d6
Then it wakes up the Handler thread, which may try to flush current buffered serialized data, but not flush all events in buffer: apm-agent-java/apm-agent-core/src/main/java/co/elastic/apm/agent/report/ApmServerReporter.java Line 225 in 24424d6
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.