DB2 在Windows平台出现ADM0501C错误解决方案

来源:互联网 发布:笔记本锁定触摸屏软件 编辑:程序博客网 时间:2024/05/19 04:52

ADM0501C  A stack overflow exception has occurred.  The DB2 instance has terminated abnormally.  To remedy this problem, you may increase the default stack size for db2syscs.exe using the db2hdr utility as follows: db2hdr /sqllib/bin/db2syscs.exe /s:<stackreserve>[,<stackcommit>] Note that increasing the default stack size will consume virtual memory space and may reduce the maximum number of concurrent connections.  Contact IBM Support for further assistance.
ADM0501C  发生了堆栈溢出异常。DB2 实例已异常终止。要解决此问题,可以按如下所示使用 db2hdr 实用程序增加 db2syscs.exe 的缺省堆栈大小:db2hdr /sqllib/bin/db2syscs.exe /s:<stackreserve>[,<stackcommit>] 注意,增加缺省堆栈大小将消耗虚拟内存空间并且可能减少并发连接的最大数目         
         
在出现上述错误后,我们的连接程序在操作数据库是总是报:
SQL30081N  检测到通信错误。正在使用的通信协议:"TCP/IP"。正在使用的通信API:"SOCKETS"。检测到错误的位置:"127.0.0.1"。检测到错误的通信函数:"connect"。协议特定的错误代码:"10061"、"*"、"*"。  SQLSTATE=08001
通过在DB2的帮助中心查询后:都是由于配置引起的错误。
  针对错误ADM11003E在网上可以找到相关的信息,但是没有明确的指出解决的办法,但是知道了可以在系统崩溃以后通过杀死db2fmp进程后,DB2数据库可以重新启动。
  我解决问题的方法是进行了下面俩项设置:
          db2 update dbm cfg USING ASLHEAPSZ 20 IMMEDIATE
          db2 update dbm cfg USING query_heap_sz 4000 IMMEDIATE
  后经过跟踪,基本上没有再发生这个问题。

修改方式如下:
  运行DB2命令行工具输入下面命令:
F:/Program Files/ibm/sqllib/misc>db2hdr.exe ../bin/db2syscs.exe /s:512,512
运行此命令需先停止DB2实例。


附上其他资料:
 When dealing with stack overflow scenarios where the stack size needs to be increased, the executable of the header should only be modified if virtual address space is a concern, i.e. if there are many agents / databases living within an instance. Otherwise, it is sufficient to increase agent_stack_sz to something above 256K, eg. 512K. Note however, that increasing agent_stack_sz actually commits the space, i.e. uses real memory.

The PROBLEM::
-by default a stack space of 256K is reserved for each thread in db2syscs.exe regardless of agent_stack_sz. This information is stored in the header of executable. The Windows default is 1MB, and we override this to conserve virtual address space. AGENT_STACK_SZ is only the committed stack - it does not represent the limit.
-If we set agent_stack_sz to 512K, the reserved stack space is actually 1MB (the granularity for reserved stack space when specified on CreateThread is 256K -> 1MB -> 2MB -> 4MB)
-This means that if we only really need 512K, we are wasting 0.5MB of address space per agent, and this can add up - All resources for databases in an instance and ALL threads (agents,prefetchers, etc.) must live within the same 2GB address space on 32-bit Windows (3GB for NT / Win2K Advanced Server / Datacenter with /3GB switch in boot.ini).

There are two ways to increase the stack size. It is not necessary to do both.
Note the committed stack will be the value of agent_stack_sz regardless,
i.e. the committed memory will be max(agent_stack_sz, stack actually used).
1. modify the header of the executable (db2hdr will do this) - this is the default reserved stack space per thread. This affects ALL threads.
2. increase agent stack size. This only affects AGENT threads. This is the simplest and is the preferred method.

Disadvantages to (1):
- must be repeated after any upgrades
- increases stack space for *ALL* threads, not just agents, which may be significant if there are a large number of prefetchers & pagecleaners. This increases use of virtual address space.

Advantages to (1):
- more granularity - saves virtual address space by requiring less stack space for agents

Disadvantages to (2):
- wastes virtual address space by reserving excess stack space which may be unacceptable if there are a large number of agents and/or address space is otherwise constrained .

Advantages to (2):
- nothing to ship, supported and documented, change carries through upgrades
- affects only agents, which usually need the extra stack space during statement compilation

SUMMARY: Use agent_stack_sz to increase stack space unless there is a concern with virtual address space.
Examples. (assuming 2GB address space) Monitor Virtual bytes using perfmon.
1. 10 agents max - increase agent_stack_sz
2. 100 agents, 1 GB current private bytes max for db2syscs.exe - increase agent_stack_sz
3. 100 agents, 1.5GB current private bytes max for db2syscs.exe - modify the header
4. 500 agents, 1GB, current private bytes max for db2syscs.exe - modify the header

IMPORTANT:
when setting agent_stack_sz , set the value to be 1 4K page less than the desired maximum.
Windows adds an additional "guard page" to the specified size.
i.e. setting a value of 256K will mean 260K, and we jump up to the next level of granularity for reserved stack, eg. 1MB.
Examples:
agent_stack_sz <= 63 to stay within the range of reserving 256K of stack space.
agent_stack_sz <= 255 to stay withini the range of reserving 1MB of stack space
agent_stack_sz <= ( 1 4K page less than the default reserved stack space set with db2hdr )

SIMPLE FIX: set agent_stack_sz to 64, which is the minimum value which will increase the reserved stack to 1MB.