0

I insert in a H2 in memory DataBase some testdata with dbunit, make an update and want to delete the testdata from the db after the test has run.

My JUnit @Before setup

databaseTester.setSetUpOperation(DatabaseOperation.INSERT);
databaseTester.setDataSet(testDataSet);
databaseTester.onSetup();

In a JUnit test method i got something like this

String sql = "UPDATE table SET column='valuenew' WHERE column='valueold'"
SQLQuery query = sessionHandler.createSQLQuery(sql);
query.executeUpdate();

My JUnit @After teardown

databaseTester.setDataSet(testDataSet);
DatabaseOperation tearDownOperation = DatabaseOperation.DELETE;
databaseTester.setTearDownOperation(tearDownOperation);
databaseTester.onTearDown();

I am not even sure if the update gets executed but the first exception i get is when onTearDown is called.

Caused by: org.h2.jdbc.JdbcSQLException: Zeitüberschreitung beim Versuch die Tabelle "DT405" zu    sperren
Timeout trying to lock table "table"; SQL statement:
delete from PUBLIC.table where column = ? [50200-175]

Seems like there is a lock already on the table. Select queries work fine but update statements fail.

Any hints what is going wrong?

Related: Timeout error trying to lock table in h2

Update: MVCC=true didn't fix the problem, i test now if a pending transaction causes the lock

Gobliins
  • 3,848
  • 16
  • 67
  • 122

0 Answers0