-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Transaction (Process ID 58) was deadlocked on lock resources
PostPosted: Wed Nov 02, 2005 4:38 pm 
Newbie

Joined: Thu Jul 28, 2005 4:23 pm
Posts: 3
Location: Ecuador
Hibernate version:
[INFO] Environment - -Hibernate 2.0.3

Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.todo1.epagos.manager.persistence.hibernate.StatusTransaccionFinal" table="PM_TRANS_F">
<id name="idTransF" column="ID_TRANS_F" type="long">
<generator class="native">
<param name="sequence">PM_SEQ_TRANS_F</param>
</generator>
</id>
<property name="idTerminal" column="ID_TERMINAL" type="integer"/>
<property name="idTerminalGw" column="ID_TERMINAL_GW" type="integer"/>
<property name="idComercioGw" column="ID_COMERCIO_GW" type="integer"/>
<property name="idAutor" column="ID_AUTOR" type="integer"/>
<property name="idManager" column="ID_MANAGER" type="integer"/>
<property name="invoiceNumber" column="INVOICE_NUMBER" type="string"/>
<property name="fecha" column="FECHA" type="timestamp"/>
<property name="fechaManager" column="FECHA_MANAGER" type="timestamp"/>
<property name="codigoRetorno" column="CODIGO_RETORNO" type="string"/>
<property name="mensajeRetorno" column="MENSAJE_RETORNO" type="string"/>
<property name="estado" column="ESTADO" type="string"/>
<property name="tipoTransaccion" column="TIPO_TRANSACCION" type="string"/>
<property name="mti" column="MTI" type="string"/>
<property name="pc" column="PC" type="string"/>
<set name="detalles" table="PM_TRANS_DET_F" lazy="false" inverse="false" cascade="none" sort="unsorted">
<key column="ID_TRANS_F"/>
<one-to-many class="com.todo1.epagos.manager.persistence.hibernate.StatusTransaccionFinalDetalle"/>
</set>
</class>
</hibernate-mapping>


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.todo1.epagos.manager.persistence.hibernate.StatusTransaccionFinalDetalle" table="PM_TRANS_DET_F">
<id name="idTransDetF" column="ID_TRANS_DET_F" type="long">
<generator class="native">
<param name="sequence">PM_SEQ_TRANS_DET_F</param>
</generator>
</id>
<property name="campo" column="CAMPO" type="string"/>
<property name="valor" column="VALOR" type="string"/>
<many-to-one name="cabeceraTransaccion" class="com.todo1.epagos.manager.persistence.hibernate.StatusTransaccionFinal" cascade="none" outer-join="auto" column="ID_TRANS_F"/>
</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Object transaction has been retrieved in a previous session.

try{
Session session = HibernateUtil.currentSession(); // Saca la sesión
tx = session.beginTransaction();

Iterator iteradorDetalles = transaccion.getDetalles().iterator();
while (iteradorDetalles.hasNext()) {
StatusTransaccionFinalDetalle detalle = (StatusTransaccionFinalDetalle) iteradorDetalles.next();
session.delete(detalle);
}
session.flush(); <---- EXCEPTION HERE !!!!!

} catch (Throwable e) {

if( tx!=null )
try{ tx.rollback(); }catch (Exception ex){}

LogPaymentManager.error(this.getClass().getName(),"ERROR AL GUARDAR TRANSACCIÓN",e);
throw new DataBaseCommException(""+e);
}finally{
HibernateUtil.closeSession();
}

Full stack trace of any exception that occurs:
Caused by: java.sql.SQLException: Transaction (Process ID 58) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
at net.sourceforge.jtds.jdbc.SqlMessage.toSQLException(SqlMessage.java:392)
at net.sourceforge.jtds.jdbc.SQLWarningChain.addOrReturn(SQLWarningChain.java:99)
at net.sourceforge.jtds.jdbc.Tds.goToNextResult(Tds.java:735)
at net.sourceforge.jtds.jdbc.TdsStatement.getMoreResults(TdsStatement.java:710)
at net.sourceforge.jtds.jdbc.TdsStatement.executeCallImpl(TdsStatement.java:302)
at net.sourceforge.jtds.jdbc.TdsStatement.internalExecuteCall(TdsStatement.java:282)
at net.sourceforge.jtds.jdbc.PreparedStatement_base.execute(PreparedStatement_base.java:135)
at net.sourceforge.jtds.jdbc.PreparedStatement_base.executeUpdate(PreparedStatement_base.java:289)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:233)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:233)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
at net.sf.hibernate.persister.EntityPersister.delete(EntityPersister.java:598)

Name and version of the database you are using:
SQL SERVER 2000 SP 4

========================================

HI: Help me please.

The error is randomic.

I remove the begin/commit block and the problem persist.

The error is very dificult to reproduce.

Please give me a light about that.

Thanks a lot.


Att.
Diego.

_________________
I just know, that I do nothing not know.


Top
 Profile  
 
 Post subject: Transaction (Process ID 58) was deadlocked on lock resources
PostPosted: Wed Nov 02, 2005 5:55 pm 
Newbie

Joined: Thu Jul 28, 2005 4:23 pm
Posts: 3
Location: Ecuador
Hibernate generate the next sentences:
Hibernate: select statustran0_.ID_TRANS_F as ID_TRANS_F, statustran0_.ID_TERMINAL as ID_TERMI2_, sta
tustran0_.ID_TERMINAL_GW as ID_TERMI3_, statustran0_.ID_COMERCIO_GW as ID_COMER4_, statustran0_.ID_A
UTOR as ID_AUTOR, statustran0_.ID_MANAGER as ID_MANAGER, statustran0_.INVOICE_NUMBER as INVOICE_7_,
statustran0_.FECHA as FECHA, statustran0_.FECHA_MANAGER as FECHA_MA9_, statustran0_.CODIGO_RETORNO a
s CODIGO_10_, statustran0_.MENSAJE_RETORNO as MENSAJE11_, statustran0_.ESTADO as ESTADO, statustran0
_.TIPO_TRANSACCION as TIPO_TR13_, statustran0_.MTI as MTI, statustran0_.PC as PC from PM_TRANS_F sta
tustran0_ where (statustran0_.ID_TERMINAL=? )and(statustran0_.INVOICE_NUMBER=? )

Hibernate: select detalles0_.ID_TRANS_F as ID_TRANS_F__, detalles0_.ID_TRANS_DET_F as ID_TRANS1___,
detalles0_.ID_TRANS_DET_F as ID_TRANS1_0_, detalles0_.CAMPO as CAMPO0_, detalles0_.VALOR as VALOR0_,
detalles0_.ID_TRANS_F as ID_TRANS_F0_ from PM_TRANS_DET_F detalles0_ where detalles0_.ID_TRANS_F=?
>>>>>>>>>>>> To getDetails
>>>>>>>>>>>> To delete
>>>>>>>>>>>> To flush
Hibernate: update PM_TRANS_F set ID_TERMINAL=?, ID_TERMINAL_GW=?, ID_COMERCIO_GW=?, ID_AUTOR=?, ID_M
ANAGER=?, INVOICE_NUMBER=?, FECHA=?, FECHA_MANAGER=?, CODIGO_RETORNO=?, MENSAJE_RETORNO=?, ESTADO=?,
TIPO_TRANSACCION=?, MTI=?, PC=? where ID_TRANS_F=?
Hibernate: delete from PM_TRANS_DET_F where ID_TRANS_DET_F=?
Borrado cardhname=123
>>>>>>>>>>>> To delete
>>>>>>>>>>>> To flush
Hibernate: delete from PM_TRANS_DET_F where ID_TRANS_DET_F=?
Borrado 37=113096765
>>>>>>>>>>>> To delete
>>>>>>>>>>>> To flush
Hibernate: delete from PM_TRANS_DET_F where ID_TRANS_DET_F=?
Borrado pin=123

Hibernate: update PM_TRANS_F set ID_TERMINAL=?, ID_TERMINAL_GW=?, ID_COMERCIO_GW=?, ID_AUTOR=?, ID_M
ANAGER=?, INVOICE_NUMBER=?, FECHA=?, FECHA_MANAGER=?, CODIGO_RETORNO=?, MENSAJE_RETORNO=?, ESTADO=?,
TIPO_TRANSACCION=?, MTI=?, PC=? where ID_TRANS_F=?



Why Hibernate generate UPDATE sentences before to delete childrens and after to delete childrens ?

When try to execute the (extrange) UPDATE ... BANG !!!! DEAD LOCK !!!!

WHY ????? :'(

The deadlock is randomic. :(

Thanks a lot.

Att.
Diego Cueva.

_________________
I just know, that I do nothing not know.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.