Hi Shawn, I've just finished writing a batch oom killer script and it seems to work fine.
I couldn't try it on the actual solr process since I'm a bit stumped on how I can make solr throw an oom at will. Although I did write another code that does throw an oom upon which this script is called and the running solr process is killed. I would like to know how I should proceed from here with submitting the code for review etc. Thanks. On Tue, 8 Mar 2016, 00:56 Shawn Heisey, <apa...@elyograg.org> wrote: > On 2/25/2016 2:06 PM, Fuad Efendi wrote: > > The best practice: do not ever try to catch Throwable or its descendants > Error, VirtualMachineError, OutOfMemoryError, and etc. > > > > Never ever. > > > > Also, do not swallow InterruptedException in a loop. > > > > Few simple rules to avoid hanging application. If we follow these, there > will be no question "what is the best way to stop Solr when it gets in OOM” > (or just becomes irresponsive because of swallowed exceptions) > > As I understand from SOLR-8539, if an OOM is thrown by a Java program > and there is a properly configured OOM script, regardless of what > happens with exception rewrapping, the script *should* kick in. Here's > an issue where this behavior was verified by a Jetty developer on a > small-scale test program which catches and swallows the OOM: > > https://issues.apache.org/jira/browse/SOLR-8539 > > Solr 5.x, when started on Linux/UNIX systems with the included shell > scripts, comes default with an "oom killer" script that is supposed to > stop Solr when OOM occurs. > > Recently it was discovered that the OnOutOfMemoryError option in the > start script for Linux/UNIX was being incorrectly specified on the > command line -- it doesn't actually work. Here's the issue for that > problem: > > https://issues.apache.org/jira/browse/SOLR-8145 > > The fix for the incorrect OnOutOfMemoryError usage will be in version > 6.0 when that version is finally released, which I think will make the > OOM killer actually work on Linux/UNIX. There is currently no concrete > information on when 6.0 is expected. If any plans for future 5.x > versions come up, that fix will likely make it into those versions as well. > > There is no OOM killer script for Windows, so this feature is not > present when running on Windows. If somebody can come up with a way for > Windows to find and kill the Solr process, I'd be happy to include it. > > Thanks, > Shawn > > -- Regards, Binoy Dalal