SQLCODE = -911,SQLSTATE = 40001,SQLERRMC = 68

时间:2018-01-16 08:01:25

标签: java hibernate exception db2 deadlock

以下是我更新记录行的方法:

@Override
public void updateCurrentStatus(Long paymentHistoryId, String currentStatus) {
    StringBuilder sb = new StringBuilder( );
    sb.append( "update PaymentHistory SET " );
    sb.append( " currentStatus = :currentStatus ," );
    sb.append( " MODIFIEDDATETIME = CURRENT TIMESTAMP " );
    sb.append( "where paymentHistoryId = :paymentHistoryId " );

    final Query updateQuery = getSession( ).createSQLQuery( sb.toString( ) );
    updateQuery.setString( "currentStatus", currentStatus );
    updateQuery.setLong( "paymentHistoryId", paymentHistoryId );
    updateQuery.executeUpdate( );
}

PaymentHistory是一个实体,paymentHistoryIdprimary key

因此,我相信我的方法只会更新PaymentHistory表的 ONE 记录。

此过程到目前为止工作正常。但昨天我打LockAcquisitionException。错误日志如下:

2018-01-16 19:56:15.379 [WebContainer : 657] ERROR c.c.i.c.a.a.ui.PaymentTrxAuthAction - [user1] - Encounter RuntimeException
org.hibernate.exception.LockAcquisitionException: could not execute native bulk manipulation query
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:105) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]
    at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:198) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]
    at org.hibernate.impl.SessionImpl.executeNativeUpdate(SessionImpl.java:1190) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]
    at org.hibernate.impl.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:357) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]

我不明白为什么我会点击could not execute native bulk manipulation query因为我只更新了1行记录。我相信could not execute native bulk manipulation query只有在我更新大量记录时才会发生。

对于org.hibernate.exception.LockAcquisitionException,我没有看到任何请求或线程拉动此行记录或更新此行记录。我相信LockAcquisitionException只会在另一个hibernate会话正在更新记录时发生,我仍然会继续更新它。但就我而言,不是。

为什么我收到此错误的任何想法?

Here is the log from DBA:

    2018-01-17-12.32.11.071146+480 E341051933A666       LEVEL: Error
PID     : 9699328              TID : 19792          PROC : db2sysc 0
INSTANCE: db2inst1             NODE : 000           DB   : SDB   
HOSTNAME: dbhm01.com
EDUID   : 19792                EDUNAME: db2hadrp.0.1 (SDB) 0
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrEduAcceptEvent, probe:20200
MESSAGE : Did not receive anything through HADR connection for the duration of 
          HADR_TIMEOUT. Closing connection.
DATA #1 : String, 30 bytes
hdrCurrentTime/hdrLastRecvTime
DATA #2 : unsigned integer, 4 bytes
1516163531
DATA #3 : unsigned integer, 4 bytes
1516163410

我对此做了一些研究,但仍然没有100%理解它。我怀疑问题是由应用程序和数据库之间的网络引起的,或者数据库服务器不稳定。有什么想法吗?

或者我可以从这个db日志获得的任何信息?

0 个答案:

没有答案
相关问题