连接池:检索丢失的数据库连接 [英] connection pooling: retrieve lost DB connection

查看:319
本文介绍了连接池:检索丢失的数据库连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为分布式事务实现两阶段提交(使用2个数据库)。我通过将网络电缆拉到我的桌面计算机,然后将其插回来来模拟DB服务器连接丢失。但是,这导致事务在执行回滚时失败,因为数据库连接对象丢失。有没有办法,我可以检索丢失的DB连接对象或强制执行应用程序尝试重新连接到相同的连接后一定的时间。
我正在使用DB2和Websphere 6.1作为应用服务器。数据库连接通过jndi查找。使用Atomikos作为事务管理器。

I am implementing 2-phase commit for a distributed transaction(using 2 Databases). I simulate a DB server connection loss by pulling the network cable to my desk Computer and then plugging it back. However, this causes the transaction to fail in executing a "rollback" as the DB connection object is lost. Is there a way that i can retrieve the lost DB connection object or enforce the application to try reconnect to the same connection after a certain timeperiod. I am using DB2 and Websphere 6.1 as the app server. DB connection is thru a jndi lookup. Using Atomikos as the Transaction Manager.

一般来说,在DB崩溃的场景中,实现两阶段提交的应用程序如何恢复(回滚)?恢复应用程序的责任还是交易经理应该这样做?

In general, how does an application implementing 2-phase commit recover(rollback) in the scenario of a DB crash? Is the recovery the application's responsibility or should the Transaction Manager do that?

推荐答案

我不认为你的问题有什么做好恢复,因为它可能发生在两阶段交易准备之前。

I don't think that your problem has anything to do with recovery because it likely occurs before the 2 phase transaction is prepared.

如果您通过拔下网络电缆模拟故障,则应用服务器将快速注意到连接断开,即当应用程序尝试执行另一个数据库操作时。但是,在DB2方面,连接看起来很空闲,DB2或DB2运行的主机系统可能需要很长时间才能注意到连接断开。一旦连接被识别为断开,回滚只会发生。在此期间,由于连接所持有的锁,您可能会遇到问题。

If you simulate a failure by unplugging the network cable, then the app server will quickly notice that the connection is broken, namely when the application attempts to execute another database operation. However, on the DB2 side, the connection simply looks idle, and it may take a long time for DB2 or the host system where DB2 runs to notice that the connection is broken. The rollback will only occur once the connection has been identified as broken. In the meantime you may have issues because of the locks held by the connection.

如果您希望减少DB2在连接上启动回滚所需的时间,那么您可能需要调整服务器上的TCP Keep-alive设置。

If you want to reduce the time it takes before DB2 initiates rollback on the connection, then you may want to tune the TCP keep-alive setting on the server.

这篇关于连接池:检索丢失的数据库连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆