DB2 CLI0129E  Allocate a handle failed

Jim Youmans
Jim Youmans used Ask the Experts™
on
DB2 on Windows Server 2012

We recently started getting this error message.
 CLI0129E  An attempt to allocate a handle failed because there are no more handles to allocate. 

Open in new window

From what I have read, this is an issue with .NET Entity Framework not releasing connections to the database.  The developers are searching the application code to see if they can find the issue but in the mean time, is there anything I can do on the DB side to help with this?

I read this:  https://www.ibm.com/support/pages/cli0129e-no-more-handles  
and this: https://www.ibm.com/support/pages/how-increase-number-statment-handles-available-your-application

but not sure I understand what they are saying.  This is the first exposure I have had to DB2 handles and not sure I understand them as well as I could.  Any insight would be much appreciated.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Tomas Helgi JohannssonDatabase Administrator / Software Engineer

Commented:
Hi,

Have you tried this ( increase number of statement handles to applications)  ?
How much memory does your Windows system have ?  
Note that CLIPkg is by default 3 and use caution when increasing the amount of packages as each package uses considerable amount of memory and resources.

https://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.5.0/com.ibm.db2.luw.apdv.cli.doc/doc/r0008961.html
https://datageek.blog/2013/09/04/binding-packages/ (see the section on CLIPKG issues )

Regards,
    Tomas Helgi
Jim YoumansSr Database Administrator

Author

Commented:
Thank you for the response.  I read the first link and have a couple of noob questions if you have a minute.

What does this command do?  
db2 "BIND @db2cli.lst BLOCKING ALL CLIPKG 6 grant public"

Open in new window

 I ran it on my test server with no issue but I don't feel comfortable doing it in prod till I understand it.  I tried using the related information links at the bottom of the page but they just take me to the main  knowledge center page.

Also, how can I see what the CLIPKG parameter is set to?  I know that the default is 3 but I don't know how to check my system to see what it is set at.

Looking at my system I don't seem to have a db2cli.ini file.  Just a sample.  Is this an issue?

My server has 32 GB for memory.

Thank you!!
Database Administrator / Software Engineer
Commented:
Hi Jim,

This bind command with the CLIPKG 6 adds total of 6 db2 system packages that handles threads/connections and their total number of cursors and other related db2 resources. By default these packages are 3. This means that you have a set of packages named like SYSXYNZZ (see below link and section) that handles your threads and their resources.

https://www.ibm.com/developerworks/data/library/techarticle/dm-0606chun/index.html (look at the "DB2 Call Level Interface (CLI) packages" section )

db2cli.ini are used by Db2 clients not servers (if I remember it correctly). I have only configured this on the client side.

If applications does not close the statement handle it will use up all such handles rather quickly or until the applications closes the connection or dies. Also if you have multiple applications connecting to your server and you only have a set of 3 packages then you are in similar situation.

By default, three small and three large packages are created. Each small package allows a maximum of 64 statement handles per connection, and each large package allows a maximum of 384 statements per connections, giving a total of 1,344 statement handles.

This quote is is from the link above. So you can see that if what you need to add to have a decent amount of handles.
And the memory it uses can be calculated using the STMTHEAP,APPLHEAPSIZE,APPL_MEMORY from DB cfg
and MAX_CONNECTIONS from DBM cfg

Regards,
     Tomas Helgi
How to Generate Services Revenue the Easiest Way

This Tuesday! Learn key insights about modern cyber protection services & gain practical strategies to skyrocket business:

- What it takes to build a cloud service portfolio
- How to determine which services will help your unique business grow
- Various use-cases and examples

Tomas Helgi JohannssonDatabase Administrator / Software Engineer

Commented:
A total of 1344 statement handles means that Db2 by default allows 1344 concurrent statements from applications that connect to Db2 to be run on the server

Regards,
    Tomas Helgi
Tomas Helgi JohannssonDatabase Administrator / Software Engineer

Commented:
Hi Jim,

Do you need any more info on this ? :)

Regards,
    Tomas Helgi
Tomas Helgi JohannssonDatabase Administrator / Software Engineer

Commented:
Hi Jim,

Do you need any more info/help on this ?

Regards,
    Tomas Helgi

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial