gpt4 book ai didi

sql-server - 64位系统上的COM+ VB6应用程序: IBM CLI Driver transaction error when connecting to DB2

转载 作者:行者123 更新时间:2023-12-03 00:23:34 27 4
gpt4 key购买 nike

我们正在尝试将用 VB6 开发的 Intranet Web 应用程序从 Windows Server 2003 迁移到 Windows Server 2008 R2,但我们遇到了两阶段提交的问题Microsoft SQL Server 2008 和 Z/OS 大型机上的 DB2 之间的事务。

在安装了 DB2 v9.7.500.702 Fixpack 8(64 位)的 Windows Server 2008 R2 上,在 COM+ 应用程序中注册的 VB6 组件在尝试在事务中更新 SQL Server 上的一个表和 DB2 上的另一个表时,返回这个错误:

[IBM][CLI Driver] SQL0998N Error occurred during transaction or heuristic processing. Reason Code = "16". Subcode = "2-80004005". SQLSTATE=58005

在调试中运行 VB6 应用程序,当 Open() 时引发异常。方法在 ADODB.Connection 上调用对象(Db2 连接)。

Db2Diag 显示:

2013-06-26-09.14.15.822000+120 I41317H405 LEVEL: Severe
PID : 5972 TID : 5588 PROC : dllhost.exe
INSTANCE: DB2 NODE : 000
APPID : *LOCAL.DB2.1306260714140626071414
EDUID : 5588
FUNCTION: DB2 UDB, XA DTP Support, MicrosoftXARMCreate, probe:364
DATA #1 : String, 69 bytes
HRESULT: 80004005
HRESULT Message: Unspecified error

系统事件查看器报告如下:

The XA Transaction Manager attempted to load the XA resource manager DLL. The call to LOADLIBRARY for the XA resource manager DLL failed: DLL=C:\PROGRAM FILES\IBM\SQLLIB\BIN\DB2APP.DLL, HR=0x800700c1, File=d:\w7rtm\com\complus\dtc\dtc\xatm\src\xarmconn.cpp Line=2446.

防火墙已关闭。
我已尝试重新安装 MSDTC。
DTCPing.exe 工作正常。
这是我的 DTC 配置:
enter image description here

我找到了this blog建议更改 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSDTC\XADLL\C:\Program Files\IBM\SQLLIB\BIN\DB2APP.DLL引用 db2app64.dll 的注册表项而不是 db2app.dll DB2 客户端安装程序通常设置的值。

按照建议更改注册表项后,事件查看器错误报告不再显示,但应用程序仍然给出此错误:

[IBM][CLI Driver][DB2] SQL0998N Error occurred during transaction or heuristic processing. Reason Code = "16". Subcode = "3-8004D00E". SQLSTATE=58005

Db2Diag 显示:

2013-06-25-12.22.37.192000+120 I39609H572 LEVEL: Severe
PID : 4364 TID : 1804 PROC : dllhost.exe
INSTANCE: DB2 NODE : 000
APPID : *LOCAL.DB2.1306251022380625102238
EDUID : 1804
FUNCTION: DB2 UDB, XA DTP Support, MicrosoftEnlistWithRM, probe:422
DATA #1 : String, 130 bytes
HRESULT: 8004D00E
HRESULT Message: The transaction has already been implicitly or explicitly committed or aborted

并检查 Db2 跟踪日志报告此错误:

pid=2664       ;tid=2020       ;time=06/25/2013-10:46:11.605   ;seq=94468      ;eventid=TRACING_STARTED                          ;;"TM Identifier='(null)                                            '" ;"MSDTC is resuming the tracing of long - lived transactions"
pid=2664 ;tid=1764 ;time=06/25/2013-10:46:11.725 ;seq=94469 ;eventid=CHECKPOINTING_STARTED ;;"TM Identifier='(null) '" ;"MSDTC is resuming the checkpointing of transactions "
pid=2664 ;tid=2020 ;time=06/25/2013-10:46:11.624 ;seq=94470 ;eventid=TRANSACTION_BEGUN ;tx_guid=4d2b1dc0-8679-44f2-a649-e440057f2423 ;"TM Identifier='(null) '" ;"transaction has begun, description :'Foo.bstx'"
pid=2664 ;tid=2020 ;time=06/25/2013-10:46:11.624 ;seq=94471 ;eventid=TRANSACTION_PROPOGATED_TO_CHILD_NODE ;tx_guid=4d2b1dc0-8679-44f2-a649-e440057f2423 ;"TM Identifier='(null) '" ;"transaction propagated to 'DVD1SSQ4' as transaction child node #1"
pid=2664 ;tid=2020 ;time=06/25/2013-10:46:11.764 ;seq=94472 ;eventid=RM_ENLISTED_IN_TRANSACTION ;tx_guid=4d2b1dc0-8679-44f2-a649-e440057f2423 ;"TM Identifier='(null) '" ;"resource manager #1002 enlisted as transaction enlistment #1. RM guid = '185bcf6e-85b5-402c-8d43-0368d4c5ee46'"
pid=2664 ;tid=2020 ;time=06/25/2013-10:46:11.858 ;seq=94473 ;eventid=ABORT_DUE_TO_CONNECTION_DOWN_FROM_RM ;tx_guid=4d2b1dc0-8679-44f2-a649-e440057f2423 ;"TM Identifier='(null) '" ;"connection to the resource manager #1002 for transaction enlistment #1 went down"
pid=2664 ;tid=2020 ;time=06/25/2013-10:46:11.858 ;seq=94474 ;eventid=TRANSACTION_ABORTING ;tx_guid=4d2b1dc0-8679-44f2-a649-e440057f2423 ;"TM Identifier='(null) '" ;"transaction is aborting"
pid=2664 ;tid=2020 ;time=06/25/2013-10:46:11.858 ;seq=94475 ;eventid=CHILD_NODE_ISSUED_ABORT ;tx_guid=4d2b1dc0-8679-44f2-a649-e440057f2423 ;"TM Identifier='(null) '" ;"abort request issued to transaction child node #1 'DVD1SSQ4'"
pid=2664 ;tid=2020 ;time=06/25/2013-10:46:11.858 ;seq=94476 ;eventid=CHILD_NODE_ACKNOWLEDGED_ABORT ;tx_guid=4d2b1dc0-8679-44f2-a649-e440057f2423 ;"TM Identifier='(null) '" ;"received acknowledgement of abort request from transaction child node #1 'DVD1SSQ4'"
pid=2664 ;tid=2020 ;time=06/25/2013-10:46:11.858 ;seq=94477 ;eventid=TRANSACTION_ABORTED ;tx_guid=4d2b1dc0-8679-44f2-a649-e440057f2423 ;"TM Identifier='(null) '" ;"transaction has been aborted"
pid=2664 ;tid=2020 ;time=06/25/2013-10:46:11.837 ;seq=94478 ;eventid=RM_ENLIST_FAILED_TRANSACTION_NOT_FOUND ;tx_guid=4d2b1dc0-8679-44f2-a649-e440057f2423 ;"TM Identifier='(null) '" ;"attempt to enlist the resource manager failed cause the transaction could not be found. Some possible reasons include, client might have already called commit or transaction might have got aborted due to timeout. RM guid = 'aa265ceb-27b0-4de0-999b-80b58dee4af8'"

Enabling Diagnostic tracing在 MS DTC 上,我们只得到这个条目:

06-25-2013 12:43:17:746 : [ a68.132c] 0x00000000 [    TRACE_XA] [TRACE_VERBOSE] LookUpXaDllPath (d:\w7rtm\com\complus\dtc\dtc\xatm\src\xatmdll.cpp@175): Looking up XA DLL 'C:\PROGRAM FILES\IBM\SQLLIB\BIN\DB2APP.DLL'
06-25-2013 12:43:17:746 : [ a68.132c] 0x00000000 [ TRACE_XA] [TRACE_VERBOSE] LookUpXaDllPath (d:\w7rtm\com\complus\dtc\dtc\xatm\src\xatmdll.cpp@294): Xa DLL Lookup completed, HR=00000000, Path='C:\Program Files\IBM\SQLLIB\BIN\DB2APP64.DLL'
06-25-2013 12:43:17:746 : [ a68. 6e4] 0x00000000 [ TRACE_XA] [TRACE_VERBOSE] CValidateTask::TaskRoutine (d:\w7rtm\com\complus\dtc\dtc\xatm\src\xataskmgr.cpp@1915): CValidateTask::TaskRoutine - calling xa_open - DLL=C:\PROGRAM FILES\IBM\SQLLIB\BIN\DB2APP.DLL, OpenString="DB=FOO,UID=FOO,PWD=FOO,TPM=MSDTC"
06-25-2013 12:43:17:777 : [ a68. 6e4] 0x00000000 [ TRACE_XA] [TRACE_VERBOSE] CValidateTask::TaskRoutine (d:\w7rtm\com\complus\dtc\dtc\xatm\src\xataskmgr.cpp@1919): CValidateTask::TaskRoutine - returned from xa_open with error=0 - DLL=C:\PROGRAM FILES\IBM\SQLLIB\BIN\DB2APP.DLL, OpenString="DB=FOO,UID=FOO,PWD=FOO,TPM=MSDTC"
06-25-2013 12:43:17:777 : [ a68. 6e4] 0x00000000 [ TRACE_XA] [TRACE_VERBOSE] CValidateTask::TaskRoutine (d:\w7rtm\com\complus\dtc\dtc\xatm\src\xataskmgr.cpp@1934): CValidateTask::TaskRoutine - calling xa_close - DLL=C:\PROGRAM FILES\IBM\SQLLIB\BIN\DB2APP.DLL
06-25-2013 12:43:17:777 : [ a68. 6e4] 0x00000000 [ TRACE_XA] [TRACE_VERBOSE] CValidateTask::TaskRoutine (d:\w7rtm\com\complus\dtc\dtc\xatm\src\xataskmgr.cpp@1943): CValidateTask::TaskRoutine - returned from xa_close with error=0 - DLL=C:\PROGRAM FILES\IBM\SQLLIB\BIN\DB2APP.DLL
06-25-2013 12:43:17:855 : [ a68.156c] 0x00000000 [ TRACE_XA] [TRACE_VERBOSE] LookUpXaDllPath (d:\w7rtm\com\complus\dtc\dtc\xatm\src\xatmdll.cpp@175): Looking up XA DLL 'C:\PROGRAM FILES\IBM\SQLLIB\BIN\DB2APP.DLL'
06-25-2013 12:43:17:855 : [ a68.156c] 0x00000000 [ TRACE_XA] [TRACE_VERBOSE] LookUpXaDllPath (d:\w7rtm\com\complus\dtc\dtc\xatm\src\xatmdll.cpp@294): Xa DLL Lookup completed, HR=00000000, Path='C:\Program Files\IBM\SQLLIB\BIN\DB2APP64.DLL'
06-25-2013 12:43:17:855 : [ a68. 6e4] 0x00000000 [ TRACE_XA] [TRACE_VERBOSE] CValidateTask::TaskRoutine (d:\w7rtm\com\complus\dtc\dtc\xatm\src\xataskmgr.cpp@1915): CValidateTask::TaskRoutine - calling xa_open - DLL=C:\PROGRAM FILES\IBM\SQLLIB\BIN\DB2APP.DLL, OpenString="DB=FOO,UID=FOO,PWD=FOO,TPM=MSDTC"
06-25-2013 12:43:17:886 : [ a68. 6e4] 0x00000000 [ TRACE_XA] [TRACE_VERBOSE] CValidateTask::TaskRoutine (d:\w7rtm\com\complus\dtc\dtc\xatm\src\xataskmgr.cpp@1919): CValidateTask::TaskRoutine - returned from xa_open with error=0 - DLL=C:\PROGRAM FILES\IBM\SQLLIB\BIN\DB2APP.DLL, OpenString="DB=FOO,UID=FOO,PWD=FOO,TPM=MSDTC"
06-25-2013 12:43:17:886 : [ a68. 6e4] 0x00000000 [ TRACE_XA] [TRACE_VERBOSE] CValidateTask::TaskRoutine (d:\w7rtm\com\complus\dtc\dtc\xatm\src\xataskmgr.cpp@1934): CValidateTask::TaskRoutine - calling xa_close - DLL=C:\PROGRAM FILES\IBM\SQLLIB\BIN\DB2APP.DLL
06-25-2013 12:43:17:886 : [ a68. 6e4] 0x00000000 [ TRACE_XA] [TRACE_VERBOSE] CValidateTask::TaskRoutine (d:\w7rtm\com\complus\dtc\dtc\xatm\src\xataskmgr.cpp@1943): CValidateTask::TaskRoutine - returned from xa_close with error=0 - DLL=C:\PROGRAM FILES\IBM\SQLLIB\BIN\DB2APP.DLL

使用 -dtc 运行 testconn20.exetestconn32.exe标志,XA 连接测试通过,没有错误。

...
Step 4: Selecting rows from SYSIBM.systables to validate existence of packages
SELECT * FROM SYSIBM.systables FETCH FIRST 5 rows only
Elapsed: 0.0468015

Step 5: Calling GetSchema for tables to validate existence of schema functions
Elapsed: 1.5132485

Step 6: Creating XA connection
DB2TransactionScope: Connection Closed.
Elapsed: 2.152869
Test passed.

在安装了 Windows Server 2003 和 Db2 9.5.800.186 FixPack8(32 位)的旧服务器上,一切运行顺利,没有任何问题;运行相同应用程序的 db2 跟踪日志显示:

pid=5188       ;tid=4516       ;time=06/25/2013-11:52:12.382   ;seq=5          ;eventid=TRACING_STARTED                          ;;"TM Identifier='(null)                                            '" ;"MSDTC is resuming the tracing of long - lived transactions"
pid=5188 ;tid=1536 ;time=06/25/2013-11:52:12.616 ;seq=6 ;eventid=CHECKPOINTING_STARTED ;;"TM Identifier='(null) '" ;"MSDTC is resuming the checkpointing of transactions "
pid=5188 ;tid=4516 ;time=06/25/2013-11:52:12.382 ;seq=7 ;eventid=TRANSACTION_BEGUN ;tx_guid=16bfbb83-9b31-4c59-a06f-c5b59978f0ca ;"TM Identifier='(null) '" ;"transaction has begun, description :'Foo.bstx'"
pid=5188 ;tid=4352 ;time=06/25/2013-11:52:12.382 ;seq=8 ;eventid=TRANSACTION_PROPOGATED_TO_CHILD_NODE ;tx_guid=16bfbb83-9b31-4c59-a06f-c5b59978f0ca ;"TM Identifier='(null) '" ;"transaction propagated to 'DVD1SSQ4' as transaction child node #1"
pid=5188 ;tid=4516 ;time=06/25/2013-11:52:12.647 ;seq=9 ;eventid=RM_ENLISTED_IN_TRANSACTION ;tx_guid=16bfbb83-9b31-4c59-a06f-c5b59978f0ca ;"TM Identifier='(null) '" ;"resource manager #1001 enlisted as transaction enlistment #1. RM guid = '3a1e3c78-a7ac-40f4-9101-d0506d78c405'"
pid=5188 ;tid=5360 ;time=06/25/2013-11:52:12.913 ;seq=10 ;eventid=RECEIVED_COMMIT_REQUEST_FROM_BEGINNER ;tx_guid=16bfbb83-9b31-4c59-a06f-c5b59978f0ca ;"TM Identifier='(null) '" ;"received request to commit the transaction from beginner"
pid=5188 ;tid=5360 ;time=06/25/2013-11:52:12.913 ;seq=11 ;eventid=CHILD_NODE_ISSUED_PREPARE ;tx_guid=16bfbb83-9b31-4c59-a06f-c5b59978f0ca ;"TM Identifier='(null) '" ;"prepare request issued to transaction child node #1 'DVD1SSQ4'"
pid=5188 ;tid=5360 ;time=06/25/2013-11:52:12.913 ;seq=12 ;eventid=RM_ISSUED_PREPARE ;tx_guid=16bfbb83-9b31-4c59-a06f-c5b59978f0ca ;"TM Identifier='(null) '" ;"prepare request issued to resource manager #1001 for transaction enlistment #1"
pid=5188 ;tid=4352 ;time=06/25/2013-11:52:12.928 ;seq=13 ;eventid=CHILD_NODE_VOTED_COMMIT ;tx_guid=16bfbb83-9b31-4c59-a06f-c5b59978f0ca ;"TM Identifier='(null) '" ;"transaction child node #1 'DVD1SSQ4' voted commit"
pid=5188 ;tid=4516 ;time=06/25/2013-11:52:12.928 ;seq=14 ;eventid=RM_VOTED_COMMIT ;tx_guid=16bfbb83-9b31-4c59-a06f-c5b59978f0ca ;"TM Identifier='(null) '" ;"resource manager #1001 voted commit for transaction enlistment #1"
pid=5188 ;tid=1932 ;time=06/25/2013-11:52:12.944 ;seq=15 ;eventid=TRANSACTION_COMMITTED ;tx_guid=16bfbb83-9b31-4c59-a06f-c5b59978f0ca ;"TM Identifier='(null) '" ;"transaction has got committed"
pid=5188 ;tid=1932 ;time=06/25/2013-11:52:12.944 ;seq=16 ;eventid=CHILD_NODE_ISSUED_COMMIT ;tx_guid=16bfbb83-9b31-4c59-a06f-c5b59978f0ca ;"TM Identifier='(null) '" ;"commit request issued to transaction child node #1 'DVD1SSQ4'"
pid=5188 ;tid=1932 ;time=06/25/2013-11:52:12.944 ;seq=17 ;eventid=RM_ISSUED_COMMIT ;tx_guid=16bfbb83-9b31-4c59-a06f-c5b59978f0ca ;"TM Identifier='(null) '" ;"commit request issued to resource manager #1001 for transaction enlistment #1"
pid=5188 ;tid=4352 ;time=06/25/2013-11:52:12.944 ;seq=18 ;eventid=CHILD_NODE_ACKNOWLEDGED_COMMIT ;tx_guid=16bfbb83-9b31-4c59-a06f-c5b59978f0ca ;"TM Identifier='(null) '" ;"received acknowledgement of commit request from transaction child node #1 'DVD1SSQ4'"
pid=5188 ;tid=4736 ;time=06/25/2013-11:52:12.944 ;seq=19 ;eventid=RM_ACKNOWLEDGED_COMMIT ;tx_guid=16bfbb83-9b31-4c59-a06f-c5b59978f0ca ;"TM Identifier='(null) '" ;"received acknowledgement of commit request from the resource manager #1001 for transaction enlistment #1"
pid=5188 ;tid=4056 ;time=06/25/2013-11:53:07.118 ;seq=20 ;eventid=TRACING_STOPPED ;;"TM Identifier='(null) '" ;"MSDTC is suspending the tracing of long - lived transactions due to lack of activity"

您知道 MSDTC(64 位)是否支持从 32 位应用程序(Dllhost.exe 32 位或 Vb6.exe 32 位)调用的两阶段提交事务吗?
TestConn32.exe 可以正常工作并通过 dtc 测试,没有任何问题(在上述 Db2app64.dll 修复之后),因此看起来不存在 32 位兼容性问题。
我已经尝试将 DB2 驱动程序从 32 位更改为 64 位,但问题仍然存在。

有什么提示吗?

最佳答案

我终于找到了问题所在,回想起来,以下修复似乎是显而易见的!

据记录here ,如果 MTS 或 COM+ 对象使用 ADO 访问数据库,则必须关闭 OLE DB 资源池,以便 ODBC 的 Microsoft OLE DB 提供程序不会干扰 ODBC 连接池。

HKEY_CLASSES_ROOT\CLSID\{c8b522cb-5cf3-11ce-ade5-00aa0044773d} 键的 OLEDB_SERVICES DWORD 值必须设置为:

0xfffffffc - All services enabled except pooling and auto-enlistment

这是解决方法吗?不,这个键已经正确设置了!
使用 ProcMon 观看所有注册表事件,我发现 Dllhost.exe 32 位读取另一个键 (WoW6432Node) 的 OLEDB_SERVICES:

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Wow6432Node\CLSID{c8b522cb-5cf3-11ce-de5-00aa0044773d}

操作系统使用此键为在 64 位版本的 Windows 上运行的 32 位应用程序提供 HKEY_LOCAL_MACHINE\SOFTWARE 的单独 View 。

OLEDB_SERVICES 设置为 0xffffffffc 最终成功了。

关于sql-server - 64位系统上的COM+ VB6应用程序: IBM CLI Driver transaction error when connecting to DB2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17298740/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com