如何杀死从 jboss 超时的数据库事务 [英] How to kill db transaction that timed out from jboss

查看:20
本文介绍了如何杀死从 jboss 超时的数据库事务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 jboss 4.2.3.

I use jboss 4.2.3.

它有设置TransactionTimeout"(在 jboss-service.xml 中),指定允许事务执行多长时间.

It has setting "TransactionTimeout" (in jboss-service.xml), that specifies how long Transaction is allowed to execute.

不幸的是,当超时过去时,执行并没有立即中止,如果事务正在做某事,只会将其标记为稍后回滚.

Unfortunately, when the timeout passes, the execution isn't aborted right now, if the transaction is doing something, only it is marked to be rolled back later.

效果是——当我有一个持久的事务并且线程在preparedStatement.execute上等待,并且当TransactionTimeout过去时,什么也没发生,客户端仍然挂起,只有当preparedStatement完成时,才会出现事务被滚动的异常回来了.

The effect is - when I have long lasting transaction and thread is wainting on preparedStatement.execute for example, and when the TransactionTimeout passes, nothing happend, client still hang, only when the preparedStatement finishes, there is Exception that transaction was rolled back.

我尝试了来自 http://management 的拦截器-platform.blogspot.com/2008/11/transaction-timeouts-and-ejb3jpa.html 但它只是将线程标记为中断,大多数方法在执行时不会检查这个,所以效果是一样的.

I tried the interceptor from http://management-platform.blogspot.com/2008/11/transaction-timeouts-and-ejb3jpa.html but it only markse thread as interrupted, most methods won't check for this when executing, so effect is the same.

我也尝试过设置preparedStatement.setQueryTimeout,但是在Oracle(我们使用的)上,它等待中止会话,直到oracle想要这样做(例如它不会中止正在执行的plsql过程dbms_lock.sleep(..)).

I've tried also setting preparedStatement.setQueryTimeout, but on Oracle (which we use), it waits with aborting session till oracle feels like doing it (for example it won't abort plsql procedure that is doing dbms_lock.sleep(..)).

我想终止与该事务关联的数据库会话,该会话已超时 - 我知道它是哪个事务,以及它与哪个线程关联(因为我使用了上面给出的链接中的拦截器),但我不知道不知道如何获取事务绑定的会话 - 我必须获取它,杀死它 - 然后线程将被中断.

I would like to kill database session associated with the transaction, that timed out - I know which transaction it is, and with which thread it is associated (because I use the interceptor from the link I given above), but I don't know how to get session the transaction is bound to - I have to get it, to kill it - and then the thread will get interrupted.

我是否缺少更简单的解决方案,或者完全错误:)?

Am I missing easier solution, or doing it completely wrong :) ?

推荐答案

刚刚对这个话题做了一些研究.有一个 JTA 配置参数 InterruptThreads,默认为 false.阅读文档,这意味着线程不会被中断,而只是如您所说的那样标记为回滚.

Just did some research on this topic. There is an JTA configuration parameter InterruptThreads, which defaults to false. Reading the docs, this means that the thread will NOT be interrupted but merely marked for rollback as you said.

听起来选项是:1) 将 InterruptThreads(在 jboss-service.xml 中)设置为 true 和2) 还有一些关于定义您自己的CheckedAction"类的讨论,该类包含在事务处理和终止过程中.

Sounds like the options are: 1) set InterruptThreads (in jboss-service.xml) to true and 2) Also some discussion on defining your own 'CheckedAction' class, which is included in the transaction handling and termination process.

看起来在默认设置下,线程基本上被允许到达某个点,它会回滚您的更新.

Looks like with the default settings, the thread is basically allowed to get to some point where it will rollback your update.

还有事务收割者配置,默认为 2 分钟 - 他们检查哪些事务可能已超时 - 所以默认超时为 5 分钟,加上 2 分钟收割者 - 最坏的情况,假设您中断线程,你可以等7分钟.

There's also the transaction reaper configuration, which default to 2 minutes - where they check on which transactions may have timeed out - so with the default timeout of 5 minutes, plus the 2 minute reaper - worst case, assuming you interrupt threads, you could wait 7 minutes.

这篇关于如何杀死从 jboss 超时的数据库事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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