当CICS REGION系统在空闲时cicsas个数从maxserver下降到minserver时,会出现cics region 异常down的现象。
Cics console中错误日志如下:
SERVICE_MESSAGE 12/05/04 12:22:56.115751675 xswork 78202/0001 : Traceback file '/var/cics_regions/xswork/dumps/dir1/cicsas78202.traceback' for transaction ' XA_CLOSE: Turned exception exc_e_illaddr into XAER_RMERR ERZ080035E/0805 12/05/04 12:22:56.127269406 xswork 78202/0001 : Abnormal termination U8035. XA_CLOSE returned a Resource Manager error when closing 'Sin gle Phase Informix' using XA_CLOSE string ''. ' SQLCODE 0, Unknown error messag e 0. ' ERZ010003I/0094 12/05/04 12:22:56.127556116 xswork 78202/0001 : CICS is p erforming region abnormal termination in process 'cicsas' ERZ052004I/0602 12/05/04 12:22:56.127992717 xswork 78202/0001 : Dump to ' SYSA0001.dmp' started. |
l AIX 5.2 ML04
l Informix ids 9.40.FC4
l Informix csdk 2.81.UC3 (/Informix/bin/check_version csdk)
l Informix conn 2.81.FC2R2
l DCE 3.2 +PTF 4
l Encina 5.1
l CICS 5.1 + CICS PTF1
l 一阶段提交
l RD中的MinServer=3 ,MaxServer=15
l RD中的ClassMaxTasks=1,1,1,1,1,1,1,1,1,8
l TD中的 CPMI: Tclass=10
l CICS通过Informix conn 访问 Informix IDS,采用tcpip连接方式
#include $include sqlca; main( void ) { $char jshzh[23]; char *CommArea; EXEC CICS ADDRESS EIB( dfheiptr ); EXEC CICS ADDRESS COMMAREA( CommArea ); memset(jshzh,0,sizeof(jshzh)); strcpy(jshzh,"1234567890123456789012"); jshzh[22]=''; printf("************ zh[%s]n",jshzh); EXEC SQL declare zh_cur1 cursor for select * from fhdgckfhz where zh=:jshzh for update; if (sqlca.sqlcode !=0) { printf("declare zh_cur1 err zh[%s]n",jshzh); EXEC CICS SYNCPOINT ROLLBACK; EXEC CICS RETURN; } EXEC SQL open zh_cur1; if (sqlca.sqlcode !=0) { printf("open zh_cur1 err sqlca.sqlcode[%s]n",sqlca.sqlcode); EXEC CICS SYNCPOINT ROLLBACK; EXEC CICS RETURN; } EXEC SQL close zh_cur1; if (sqlca.sqlcode !=0) { printf("close zh_cur1 err sqlca.sqlcode[%s]n",sqlca.sqlcode); EXEC CICS SYNCPOINT ROLLBACK; EXEC CICS RETURN; } EXEC SQL free zh_cur1; if (sqlca.sqlcode !=0) { printf("free zh_cur1 err sqlca.sqlcode[%s]n",sqlca.sqlcode); EXEC CICS SYNCPOINT ROLLBACK; EXEC CICS RETURN; } EXEC CICS RETURN; } |
通过测试各种交易,发现js3101交易每次测试都会出现cics异常。所以最终定位js3101交易,采用逐步注释的办法,发现问题与如下语句有关:
EXEC SQL declare zh_cur1 cursor for select * from fhdgckfhz where zh=:jshzh for update;
如果在应用中注释上述语句,系统运行正常。基于此种原因,我写了一个上述测试用例,进行如下测试。
l 采用上述的测试用例进行并发测试,使cicsas的并发数达到了Maxserver的个数。
l 应用程序中只定义cursor,不close和free cursor。
测试条件 | 测试结果 | |
1. | 一阶段提交; MinServer=3 ;MaxServer=15; 关键语句:EXEC SQL declare zh_cur1 cursor for select * from fhdgckfhz where zh=:jshzh for update; | 当cicsas个数从Maxserver下降时,会出现cics region 异常终止的现象。 |
2. | 一阶段提交; MinServer=3 ;MaxServer=15; 关键语句:EXEC SQL declare zh_cur1 cursor for select * from fhdgckfhz where zh=’12345678901234567890123’ for update; | 当cicsas个数从Maxserver下降时,cics region 表现正常。 |
3. | 一阶段提交; MinServer=15 ;MaxServer=15; 关键语句:EXEC SQL declare zh_cur1 cursor for select * from fhdgckfhz where zh=:jshzh for update; | 当cicsas个数从Maxserver下降时,cics region 表现正常。 |
4. | 两阶段提交; MinServer=3 ;MaxServer=15; 关键语句:EXEC SQL declare zh_cur1 cursor for select * from fhdgckfhz where zh=:jshzh for update; | 当cicsas个数从Maxserver下降时,cics region 表现正常;当会出现个别交易被hang的现象。 |
l 针对在应用程序中是否关闭和释放cursor的情况,我做了如下测试,结果如下:
IFX_AUTOFREE=1 | EXEC SQL set autofree enabled; | Close cursor | Free cursor | Cics region | |
1 | n | n | y | n | down |
2 | n | n | y | y | normal |
3 | n | y | y | n | normal |
4 | n | y | n | n | down |
5 | y | n | y | n | normal |
l 关于Enabling the AUTOFREE Feature
You can enable the AUTOFREE feature for an ESQL/C application in either of the following ways:
(1)Set the IFX_AUTOFREE environment variable to 1 (one).
When you use the IFX_AUTOFREE environment variable to enable the AUTOFREE feature, you automatically free cursor memory when cursors in any thread of the program are closed.
(2)Execute the SQL statement, SET AUTOFREE.
With the SET AUTOFREE statement, you can enable the AUTOFREE feature for a particular cursor. You can also enable or disable the feature in a particular connection or thread.
Warning: Be careful when you enable the AUTOFREE feature in legacy ESQL/C applications. If a legacy application uses the same cursor twice, it generates an error when it tries to open the cursor for the second time. When the AUTOFREE feature is enabled, the database server automatically frees the cursor when it closes it. Therefore,the cursor does not exist when the legacy application attempts to open it a second time, even though the application does not explicitly execute the FREE statement.
使用测试用例进行上述测试,从测试结果中发现
l 在cics和informix一阶段时:
如果minserver
如果minserver=maxserver时,进行测试时,如果对定义和打开的cursor不close 和 free cursor,当cics region系统空闲时,cicsas个数从maxserver下降时,cics region 正常。
l 在cics和informix二阶段时:
如果minserver
l 关于目前遇到的上述问题,已经提交给了IBM TSC的技术支持小组,并把相关的测试程序和环境发给他们了,IBM TSC并已经针对这个问题提交给了IBM 实验室。
l 关于应用程序是否是需要显示free cursor,我找到了如下资料:
With the OPTOFC feature disabled, a static cursor is freed when it is closed. When ESQL/C reaches a CLOSE statement for a static cursor,it actually sends a message to close the cursor and free memory associated with this cursor. However, dynamic cursors are not implicitly freed when they are closed. 另外: The default value of the OPTOFC environment variable is 0 (zero). 0 This value disables the OPTOFC feature for all threads of the application. |
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/67233/viewspace-904102/ ,如需转载,请注明出处,否则将追究法律责任。