본문 바로가기

WAS/WebLogic

java.lang.OutOfMemoryError에 관하여 - panic action

728x90

java.lang.OutOfMemoryError이 됐을 경우 SHUTDOWN이 되는 케이스가 있고 안 되는 케이스가 있었다.

java.lang.OutOfMemoryError가 발생하여 SHUTDOWN이 되기 위해서는 panic condition이 충족 되어야 한다.

 

panic condition 이 발생한 다음 2가지 경우를 예를 들어 보자.
#1. Weblogic failing to start due to lack of Java Heap space ( Doc ID 2703087.1 )
#2. WebLogic Server Shutdown with the Error "java.lang.OutOfMemoryError: GC overhead limit exceeded" and "There is a panic condition in the server. The server is configured to exit on panic" ( Doc ID 2950827.1 )

#1. Weblogic failing to start due to lack of Java Heap space ( Doc ID 2703087.1 )
...
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "[STANDBY] ExecuteThread: '24' for queue: 'weblogic.kernel.Default (self-tuning)'"
***************************************************************************
The WebLogic Server encountered a critical failure
java.lang.OutOfMemoryError: Java heap space
Reason: There is a panic condition in the server. The server is configured to exit on panic
***************************************************************************
...

#2. WebLogic Server Shutdown with the Error "java.lang.OutOfMemoryError: GC overhead limit exceeded" and "There is a panic condition in the server. The server is configured to exit on panic" ( Doc ID 2950827.1 )
...
The WebLogic Server encountered a critical failure
java.lang.OutOfMemoryError: GC overhead limit exceeded
at weblogic.application.ComponentInvocationContextManagerImpl.setCurrentComponentInvocationContext(ComponentInvocationContextManagerImpl.java:225)
at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:343)
at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:337)
at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:57)
at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:644)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:415)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:355)
Reason: There is a panic condition in the server. The server is configured to exit on panic

***************************************************************************

#1 의 경우 weblogic 구동시 java.lang.OutOfMemoryError: Java heap space 가 발생하면서 

panic condition 이 발생, #2 의 경우에는 어플리케이션 실행도중 weblogic.application.ComponentInvocationContextManagerImpl.setCurrentComponentInvocationContext 에서 java.lang.OutOfMemoryError: GC overhead limit exceeded 가 발생하면서 panic condition 이 발생.


즉, weblogic 소스에서 OOM 이 handle 가능한 경우에는, panic condition 으로 빠져 결국 exit 되게 됩니다.

 

하지만 weblogic 소스 외적인 요소, javax.imageio.stream.MemoryCache.loadFromStream 실행시 OOM 이 발생하면,

weblogic 이 해당 OOM 을 처리할 수 없어 panic condition 이 충족되지 못하여 exit 되지 못한다.

이럴 경우 이전에 inconsistent state 가 되어 재구동이 필요하다고 볼 수 있다. 

 

PanicAction
Exit the server process when the kernel encounters a panic condition like an unhandled OOME. An unhandled OOME could lead to inconsistent state and a server restart is advisable if backed by node manager or a HA agent.

https://docs.oracle.com/en/middleware/fusion-middleware/weblogic-server/12.2.1.4/wlmbr/core/index.html

 

 

추가로, OutOfMemeory 에러 발생시 JVM 은 default 로 OutOfMemeory 가 발생한 thread 를 kill을 수행 하지만,

어플리케이션 자체가 exit 되지는 않는다.

어플리케이션을 exit 시키려면 다음 2가지 옵션 중 하나를 사용해야한다.
-XX:+ExitOnOutOfMemoryError
-XX:+CrashOnOutOfMemoryError