You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by "Chris Nauroth (JIRA)" <ji...@apache.org> on 2015/05/21 00:50:59 UTC
[jira] [Updated] (ZOOKEEPER-2185) Document recommendation to use
-XX:HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError="kill %p" for
server.
[ https://issues.apache.org/jira/browse/ZOOKEEPER-2185?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Chris Nauroth updated ZOOKEEPER-2185:
-------------------------------------
Attachment: ZOOKEEPER-2185.001.patch
I'm attaching a patch that sets these options in zkServer.sh and zkServer.cmd and also updates documentation.
The syntax for referring to the pid on Windows might look a little strange, so here is an explanation. The {{%}} character is reserved in cmd syntax for referring to variables: {{%1}}, {{%2}}, etc. We don't want cmd to try to interpret {{%p}} as a variable. Instead, we want that literal passed right into Java, which will replace it with the pid. To escape it, you use two {{%}} characters next to each other. That gives us {{%%p}}. However, we need this to survive 2 cmd invocations: once for execution of zkServer.cmd and a second time when Java executes it through {{cmd /c}}. That means we need to double-escape, which then gives us the final result of {{%%%%p}}.
To test this, I faked a change in {{QuorumPeerMain#main}} to keep allocating memory in a tight loop until it triggered an {{OutOfMemoryError}}. I saw that it dumped an hprof file and killed the process. I did this test on both Linux and Windows.
> Document recommendation to use -XX:HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError="kill %p" for server.
> --------------------------------------------------------------------------------------------------------------
>
> Key: ZOOKEEPER-2185
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2185
> Project: ZooKeeper
> Issue Type: Improvement
> Components: documentation
> Reporter: Chris Nauroth
> Assignee: Chris Nauroth
> Priority: Minor
> Attachments: ZOOKEEPER-2185.001.patch
>
>
> Continuing to run a server process after it runs out of memory can lead to unexpected behavior. This issue proposes that we update documentation to recommend adding these JVM options:
> # {{-XX:HeapDumpOnOutOfMemoryError}} for help with post-mortem analysis of why the process ran out of memory.
> # {{-XX:OnOutOfMemoryError="kill %p"}} to kill the JVM process, under the assumption that a process monitor will restart it.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)