XID提升0:未知 [英] resume for XID raised 0: unknown

查看:151
本文介绍了XID提升0:未知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Spring 3.0.5,Hibernate 3.6.7,Atomikos TransactionEssentials 3.7.0和MySQL 5.5

我最近遇到了这个问题, 8小时后超时,并被服务器重置,导致消息resume for XID'???'raise 0:unknown



以下是我的数据源配置:

 <豆ID = myDataSource 
类= com.atomikos.jdbc.AtomikosDataSourceBean
INIT-方法= 初始化
破坏法= 接近
依赖-ON = myConfigurer >
将属性名= uniqueResourceName 值= myPUDataSource/>
将属性名= xaDataSourceClassName 值= $ CONF {database.XAdriver}/>
将属性名= poolSize 值= 10/>
将;属性名= xaProperties >
将道具>
将支撑键= 用户 > $ CONF {database.user}< /丙>
将丙键= 密码 > $ CONF {database.pa提供ssword}< /丙>
< prop key =URL> $ CONF {database.url}< / prop>
< prop key =pinGlobalTxToPhysicalConnection> true< / prop>
< prop key =autoReconnect> true< / prop>
< /道具>
< / property>
< / bean>

正如我在调查中发现autoReconnect = true选项只会在延迟后重新连接故障连接2秒(这是配置我认为)。
浏览网页我发现解决方案建议在MySQL服务器中增加wait_timeout,我认为这不是一个真正的解决方案。
应用程序应该能够处理无效连接并自动重新连接,因为可能还有其他问题导致连接丢失。
(而且我不想对应用程序使用任何类型的指令)



最后我找到了一个很好的解决方案,我将发布答案,以帮助面临相同或类似问题的人。

解决方案

通过插入以下行:

 < property name =testQueryvalue =SELECT 1/> 

在数据源的配置上,似乎连接在使用之前经过测试,如果连接已死,则重新连接。
我试着用 wait_timeout = 60 ,甚至在我的应用程序正在运行时重新启动MySQL服务器...



结果:没有更多异常和错误!


I am using Spring 3.0.5, Hibernate 3.6.7, Atomikos TransactionEssentials 3.7.0 and MySQL 5.5

I recently faced the problem, that connections in my connectionpool timedout after 8 hours and were reset by the server causing a message "resume for XID '???' raised 0: unknown

Here is my datasource configuration:

<bean id="myDataSource"
      class="com.atomikos.jdbc.AtomikosDataSourceBean"
      init-method="init"
      destroy-method="close"
      depends-on="myConfigurer">
    <property name="uniqueResourceName" value="myPUDataSource" />
    <property name="xaDataSourceClassName" value="$CONF{database.XAdriver}" />
    <property name="poolSize" value="10" />
    <property name="xaProperties">
        <props>
            <prop key="user">$CONF{database.user}</prop>
            <prop key="password">$CONF{database.password}</prop>
            <prop key="URL">$CONF{database.url}</prop>
            <prop key="pinGlobalTxToPhysicalConnection">true</prop>
            <prop key="autoReconnect">true</prop>
        </props>
    </property>
</bean>

As I was investigating I found out that the option autoReconnect=true only reconnects my faulted connection after a delay of 2 seconds (which is configurabe I think). Browsing the web I found solutions suggesting to increase wait_timeout in the MySQL-Server, which I think is not a real solution. The application should be able to handle dead connections and reconnect automatically, because there may be other issues causing a connection loss, too. (And I don't want to make any directives to Servers whatever kind the application uses).

At last I found a good solution for this, which I will post as answer to help people facing the same or similar problems.

解决方案

By inserting the line:

<property name="testQuery" value="SELECT 1"/>

on the data source's configuration, it seems the connection is tested before use and reconnected if it's dead. I tried it with wait_timeout=60 and even with a restart of the MySQL-Server while my application was running...

Result: no more Exceptions and Errors!

这篇关于XID提升0:未知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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