Hibernate锁等待问题

时间:2011-05-30 15:56:34

标签: java mysql hibernate connection-pooling

我们有一个Java应用程序,它监听sockects并将解析后的信息记录到MySql数据库。我们使用hibernate作为ORM层。整个持久性过程由专用线程处理。实体以20个为一组插入和更新,最大插入速率为30插入/秒,最大更新速率为30个更新/秒,在6核24GB-RAM linux机器上。目前数据库大小约为16GB。应用程序在平稳运行40分钟后挂起,但以下情况除外:     org.hibernate.util.JDBCExceptionReporter - SQL Error: 1205, SQLState: 41000 Lock wait timeout exceeded; try restarting transaction javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute update query

即使该行上存在锁定,该线程也必须永远不会停止,如果可能强行释放该行上的锁定,我该如何保证这种行为?任何帮助将不胜感激。您可以在下面找到我们的休眠配置:

<properties>
  <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
  <property name="hibernate.connection.url" value="jdbc:mysql://**************:3306/*********?useUnicode=yes;characterEncoding=UTF-8;rewriteBatchedStatements=true;includeThreadNamesAsStatementComment=true"/>
  <property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
  <property name="hibernate.connection.autocommit" value="false"/>
  <property name="hibernate.connection.useUnicode" value="true"/>
  <property name="hibernate.connection.characterEncoding" value="UTF-8"/>
  <property name="hibernate.connection.show_sql" value="true"/>
  <property name="hibernate.connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider"/>
  <property name="hibernate.connection.zeroDateTimeBehavior" value="convertToNull"/>
  <property name="hibernate.c3p0.max_size" value="100"/>
  <property name="hibernate.c3p0.min_size" value="0"/>
  <property name="hibernate.c3p0.acquire_increment" value="1"/>
  <property name="hibernate.c3p0.idle_test_period" value="300"/>
  <property name="hibernate.c3p0.max_statements" value="0"/>
  <property name="hibernate.c3p0.timeout" value="100"/>
  <property name="hibernate.c3p0.autoCommitOnClose" value="false"/>
  <!-- JDBC connection pool (use the built-in) -->
  <!--Hibernate Batch Process Best Practices -->
  <property name="hibernate.order_updates" value="true"/>
  <property name="hibernate.order_inserts" value="true"/>
  <property name="hibernate.jdbc.batch_size" value="15" />
</properties>

0 个答案:

没有答案