{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/14325","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/14325/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/14325/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/14325/events","html_url":"https://github.com/elastic/elasticsearch/issues/14325","id":113717843,"number":14325,"title":"Circuit breaker to manage native script plugin memory usage","user":{"login":"ppf2","id":7216393,"avatar_url":"https://avatars.githubusercontent.com/u/7216393?v=3","gravatar_id":"","url":"https://api.github.com/users/ppf2","html_url":"https://github.com/ppf2","followers_url":"https://api.github.com/users/ppf2/followers","following_url":"https://api.github.com/users/ppf2/following{/other_user}","gists_url":"https://api.github.com/users/ppf2/gists{/gist_id}","starred_url":"https://api.github.com/users/ppf2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ppf2/subscriptions","organizations_url":"https://api.github.com/users/ppf2/orgs","repos_url":"https://api.github.com/users/ppf2/repos","events_url":"https://api.github.com/users/ppf2/events{/privacy}","received_events_url":"https://api.github.com/users/ppf2/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/:Circuit%20Breakers","name":":Circuit Breakers","color":"009800"},{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/enhancement","name":"enhancement","color":"4a4ea8"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-28T00:32:02Z","updated_at":"2015-10-28T20:38:18Z","closed_at":null,"body":"Not sure if this goes into #11070 or not. \r\nUsers can pretty do anything in native script plugins (for various reasons), eg. building large arraylists, using java's regex pattern matcher, etc.. that can end up using a ton of memory.  It will be difficult for the request circuit breaker to estimate the amount of memory the native plugin will use and prevent it from running.  So it can be useful to provide a circuit breaker that allows for a memory cap that kills off queries that may have a native plugin using a lot of heap once it hits a user defined memory limit."},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments/151983502","html_url":"https://github.com/elastic/elasticsearch/issues/14325#issuecomment-151983502","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/14325","id":151983502,"user":{"login":"dakrone","id":19060,"avatar_url":"https://avatars.githubusercontent.com/u/19060?v=3","gravatar_id":"","url":"https://api.github.com/users/dakrone","html_url":"https://github.com/dakrone","followers_url":"https://api.github.com/users/dakrone/followers","following_url":"https://api.github.com/users/dakrone/following{/other_user}","gists_url":"https://api.github.com/users/dakrone/gists{/gist_id}","starred_url":"https://api.github.com/users/dakrone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dakrone/subscriptions","organizations_url":"https://api.github.com/users/dakrone/orgs","repos_url":"https://api.github.com/users/dakrone/repos","events_url":"https://api.github.com/users/dakrone/events{/privacy}","received_events_url":"https://api.github.com/users/dakrone/received_events","type":"User","site_admin":false},"created_at":"2015-10-28T20:38:18Z","updated_at":"2015-10-28T20:38:18Z","body":"@ppf2 I'm not sure this is feasible right now, with the way the circuit breakers work there is a requirement that requests for additional memory are funneled through a single point (where we can track usage and freeing), we already have this for fielddata and requests (ie BigArrays), but for native scripts, they are allocating memory directly on the JVM heap, so I don't think there is a hook we can use to increment/decrement memory for.\r\n\r\nNative scripts could always use our circuit-breaking BigArrays instance, however, to generate new arrays of different types, in which case it will go through the requests breaker."}}