-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Memory leak with errorHandlers #13458
Comments
Right, I totally forgot about that. I stumbled across this while creating the context view. I failed to find a way to reliably clean up the error handlers. As far as I could determine fixing it would require changing every code path that performs courier requests (and much of the internal queue/retry logic). So I created Thanks a lot for pointing this out, @stacey-gammon! |
Would it be possible to do something like have Something like: SourceAbstract.prototype.onResults = function (handler) {
const self = this;
return new PromiseEmitter(function (resolve, reject) {
const defer = Promise.defer();
defer.promise.then((response) => {
const returnValue = resolve(response);
_.remove(errorHandlers, handler => handler.source === self);
return returnValue;
}, reject);
self._createRequest(defer);
}, handler);
}; Otherwise, won't anyone who still uses |
I tried to recall my investigations from a few months ago with only limited success. There were problems with the various ways in which requests can be triggered and retried (not to mention the segmented request stuff), the order in which the error and success handlers were called, and... others. I will dive into this over the next days and update you with my findings. Thanks again! 😄 |
The problem with removing the error handler in Cleaning this up would mean to replace these |
After trying to investigate some of the memory issues in our system I think I found one with errorHandlers in the courier.
This line right here: https://github.com/elastic/kibana/blob/master/src/ui/public/courier/data_source/_abstract.js#L163 pushes an object with a defer and a search source (which can be large) onto an errorHandlers array.
This errorHandlers array is only ever dealt with, as far as I can tell, in
error_handler.handleError
. Even there it doesn't seem to be removed from the array.Running a request every 1 second for 20 visualizations in a dashboard led me here via heap snapshots. If I simply remove the
portion of the code, my testing showed a dramatic decrease in leaked memory - from about 10MB to 1MB over a 60s period.
cc @spalger @weltenwort
The text was updated successfully, but these errors were encountered: