IBM Support

How to avoid SQL4302N caused by Java heap exhaustion when running Java routines in parallel.

Troubleshooting


Problem

An application that calls Java routines has been running for a while without an error, but it start failing with SQL4302N on some connections.
A connection receiving SQL4302N continue to fail with the same error, while other connections are unaffected.

Symptom

An application that runs Java routines(Stored Procedures or UDFs) might receive a similar message like below.
----------------------------------------------------------------------
SQL4302N  Procedure or user-defined function "<fuction schema>.<udf name> specific
name "SQLXXXXXXXXXXXXXXX" aborted with an exception "Java heap space".
SQLSTATE=38501
----------------------------------------------------------------------

At the same time, the following error will be recorded in db2diag.log.
----------------------------------------------------------------------
2019-04-09-00.19.47.520000-420 I6227F421            LEVEL: Warning
PID     : 5556                 TID : 4796           PROC : db2fmp64.exe
INSTANCE: DB2                  NODE : 000           DB   : XXXX
APPID   : *LOCAL.DB2.190409070610
HOSTNAME: XXXXXX
EDUID   : 4796
FUNCTION: DB2 UDB, BSU Java support, sqlejCallJavaRoutine_dll, probe:370
DATA #1 : String, 35 bytes
Java routine exited with exception.

2019-04-09-00.19.47.520000-420 E6650F492            LEVEL: Warning
PID     : 5556                 TID : 4796           PROC : db2fmp64.exe
INSTANCE: DB2                  NODE : 000           DB   : XXXX
APPID   : *LOCAL.DB2.190409070610
HOSTNAME: XXXXXX
EDUID   : 4796
FUNCTION: DB2 UDB, BSU Java support, sqlejLogExceptionToDiag, probe:1480
MESSAGE : ADM10000W  A Java exception has been caught.  The Java stack
          traceback has been written to the db2diag log file.

2019-04-09-00.19.47.520000-420 E7144F466            LEVEL: Warning
PID     : 5556                 TID : 4796           PROC : db2fmp64.exe
INSTANCE: DB2                  NODE : 000           DB   : XXXX
APPID   : *LOCAL.DB2.190409070610
HOSTNAME: XXXXXX
EDUID   : 4796
FUNCTION: DB2 UDB, BSU Java support, sqlejLogExceptionToDiag, probe:1488
DATA #1 : String, 82 bytes
java.lang.OutOfMemoryError: Java heap space
        at <library name>.<udf name>(<source file>.java:<line number>)

2019-04-09-00.19.47.520000-420 I7612F496            LEVEL: Warning
PID     : 5556                 TID : 4796           PROC : db2fmp64.exe
INSTANCE: DB2                  NODE : 000           DB   : XXXX
APPID   : *LOCAL.DB2.190409070610
HOSTNAME: XXXXXX
EDUID   : 4796
FUNCTION: DB2 UDB, routine_infrastructure, sqlerJavaCallRoutine, probe:30
MESSAGE : Error from DB2ER CallUDF.  RC:
DATA #1 : Hexdump, 4 bytes
0x0000007315DF5520 : 32EF FFFF                                  2...
----------------------------------------------------------------------

Or if we couldn't even allocate Java heap to create a Java thread, you will see the following error.
----------------------------------------------------------------------
2019-02-22-13.02.03.605000+540 I53710303F361        LEVEL: Warning
PID     : 10928                TID : 10932          PROC : db2fmp64.exe
INSTANCE: DB2                  NODE : 000
HOSTNAME: XXXXXXXX
EDUID   : 10932
FUNCTION: DB2 UDB, routine_infrastructure, sqlerMasterThreadListener, probe:300
MESSAGE : Java heap is nearly full; no thread created

2019-02-22-13.02.03.605000+540 E53710666F552        LEVEL: Warning
PID     : 1116                 TID : 5652           PROC : db2syscs.exe
INSTANCE: DB2                  NODE : 000           DB   : XXXX
APPHDL  : 0-702                APPID: XXXXXXXX.XXXX.190222040206
AUTHID  : XXXXX                HOSTNAME: XXXXXXXX
EDUID   : 5652                 EDUNAME: db2agent (XXXX)
FUNCTION: DB2 UDB, routine_infrastructure, sqlerMasterThreadReq, probe:89
MESSAGE : FMP reported it could not create a new thread
DATA #1 : Process ID, 4 bytes
10928

2019-02-22-13.02.03.605000+540 I53711220F547        LEVEL: Severe
PID     : 1116                 TID : 5652           PROC : db2syscs.exe
INSTANCE: DB2                  NODE : 000           DB   : XXXX
APPHDL  : 0-702                APPID: XXXXXXXX.XXXX.190222040206
AUTHID  : XXXXX                HOSTNAME: XXXXXXXX
EDUID   : 5652                 EDUNAME: db2agent (XXXX)
FUNCTION: DB2 UDB, routine_infrastructure, sqlerGetFmpThread, probe:6413
RETCODE : ZRC=0xFFFFFBEE=-1042
SQL1042C An unexpected system error occurred.
----------------------------------------------------------------------

Document Location

Worldwide


[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Component":"","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

To view more of this document

This document has the abstract of a technical article that is available to authorized users once you have logged on. Please use the link to actual document below to access the full document. You will be asked to log on if you are not already logged in. After log in, if you do not have the right authorization for this document, there will be instructions on what to do next.

Document Information

More support for:
Db2 for Linux, UNIX and Windows

Software version:
All Versions

Operating system(s):
AIX, HP-UX, Linux, Windows

Document number:
1118955

Modified date:
01 May 2025

UID

ibm11118955

Manage My Notification Subscriptions