Hi,

I am getting "Commit or rollback is not allowed within a trigger" under H2 
1.3.176 but I am not actually rolling anything back. As far as I understand 
the following sequence of events occurs:

1. Java code invokes: delete from PARTICIPANT where 
PARTICIPANT.LAST_SEEN_TIME < ?
2. A "after delete" trigger runs, invoking: delete from PERMISSION where ID 
= ? (at CascadeToPermission.java:80)
3. This triggers a rollback (looking at the H2 source code, caused by a 
deadlock)
4. H2 throws the following exception:

com.mysema.query.QueryException: Caught JdbcSQLException for delete from 
PARTICIPANT
where PARTICIPANT.LAST_SEEN_TIME < ?
at 
com.mysema.query.sql.DefaultSQLExceptionTranslator.translate(DefaultSQLExceptionTranslator.java:38)
 
~[querydsl-sql-3.4.0.jar:na]
at com.mysema.query.sql.Configuration.translate(Configuration.java:434) 
~[querydsl-sql-3.4.0.jar:na]
at 
com.mysema.query.sql.dml.SQLDeleteClause.execute(SQLDeleteClause.java:165) 
~[querydsl-sql-3.4.0.jar:na]
at com.vtlr.backend.row.Participant.removeOlderThan(Participant.java:262) 
~[classes/:na]
at 
com.vtlr.backend.jersey.LifecycleListener$RemoveIdleParticipants.run(LifecycleListener.java:299)
 
~[classes/:na]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 
[na:1.8.0_05]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) 
[na:1.8.0_05]
at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
 
[na:1.8.0_05]
at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
 
[na:1.8.0_05]
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
[na:1.8.0_05]
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
[na:1.8.0_05]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_05]
Caused by: org.h2.jdbc.JdbcSQLException: Commit or rollback is not allowed 
within a trigger; SQL statement:
delete from PARTICIPANT
where PARTICIPANT.LAST_SEEN_TIME < ? [90058-176]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:344) 
~[h2-1.3.176.jar:1.3.176]
at org.h2.message.DbException.get(DbException.java:178) 
~[h2-1.3.176.jar:1.3.176]
at org.h2.message.DbException.get(DbException.java:154) 
~[h2-1.3.176.jar:1.3.176]
at org.h2.message.DbException.get(DbException.java:143) 
~[h2-1.3.176.jar:1.3.176]
at org.h2.engine.Session.checkCommitRollback(Session.java:537) 
~[h2-1.3.176.jar:1.3.176]
at org.h2.engine.Session.rollback(Session.java:559) 
~[h2-1.3.176.jar:1.3.176]
at org.h2.command.Command.executeUpdate(Command.java:276) 
~[h2-1.3.176.jar:1.3.176]
at 
org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:158)
 
~[h2-1.3.176.jar:1.3.176]
at 
org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:144) 
~[h2-1.3.176.jar:1.3.176]
at 
com.vtlr.backend.database.permission.CascadeToPermission.fire(CascadeToPermission.java:80)
 
~[classes/:na]
at org.h2.schema.TriggerObject.fireRow(TriggerObject.java:204) 
~[h2-1.3.176.jar:1.3.176]
at org.h2.table.Table.fireRow(Table.java:935) ~[h2-1.3.176.jar:1.3.176]
at org.h2.table.Table.fireAfterRow(Table.java:925) ~[h2-1.3.176.jar:1.3.176]
at org.h2.command.dml.Delete.update(Delete.java:101) 
~[h2-1.3.176.jar:1.3.176]
at org.h2.command.CommandContainer.update(CommandContainer.java:79) 
~[h2-1.3.176.jar:1.3.176]
at org.h2.command.Command.executeUpdate(Command.java:254) 
~[h2-1.3.176.jar:1.3.176]
at 
org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:158)
 
~[h2-1.3.176.jar:1.3.176]
at 
org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:144) 
~[h2-1.3.176.jar:1.3.176]
at 
com.mysema.query.sql.dml.SQLDeleteClause.execute(SQLDeleteClause.java:159) 
~[querydsl-sql-3.4.0.jar:na]
... 9 common frames omitted

Expected behavior: H2 should indicate the operation failed due to a 
deadlock, as opposed to complaining about a trigger rolling back the 
transaction.

Is this a bug? If not, what am I supposed to do?

Thanks,
Gili

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to