You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Buffered events are lost when the process ends before a flush or tick #32
Adding an event or metric to the buffer wrote it to Redis immediately (persist-on-enqueue). That put a Redis round trip, up to the command timeout (5s by default) while Redis is slow, on the request path of every host call to sendEvent() / sendMetric().
The first fix on this branch moved the write off the request path: EventBuffer::add* only marks items pending, and persistPending() writes them at the end of flushBuffer() and from tick(). The trade-off is that a request that ends before any flush or tick never wrote its items, so they were lost.
I am closing that gap wherever PHP allows. The agent registers one shutdown function when Redis persistence is attached, and it calls persistPending(). That covers normal end, exit(), an uncaught exception, a fatal error, out of memory and max_execution_time. The request path still has no Redis round trip.
What cannot be fixed: SIGKILL (the OOM killer, kill -9) and SIGTERM without a host handler run no PHP code at all. I will prove all of this with child-process tests against a real Redis (bin/test_shutdown.php) and document the two unfixable cases with the reason.
I deliberately do not call fastcgi_finish_request() from the shutdown function (it would cut off output and shutdown functions the host registers later) and I do not install a SIGTERM handler (it would override the host's).
Activity