Java Spring, JPA, HSQLDB: schema created twice (rarely)

33 Views Asked by At

I have a Java/Spring application with JPA/HSQLDB as persistence layer. It's deployed on dozens of computers and normally works fine. But recently there were three occasions where the application would not start (so it's really a rare case and I wasn't able to reproduce it).

In those cases, the database was already filled with data from a previous run. Investigating the problem, the reason why the application did not start was that the schema creation was written twice into the data.script file:

SET DATABASE UNIQUE NAME HSQLDBxxx
SET DATABASE GC 0
...
ALTER TABLE PUBLIC...
-- now the same lines come again
SET DATABASE UNIQUE NAME HSQLDBxxx
SET DATABASE GC 0
...
ALTER TABLE PUBLIC...
ALTER SEQUENCE SYSTEM_LOBS.LOB_ID RESTART WITH 2 -- the "2" looks suspicious
...
continues with data insertion etc.

After removing the duplicate schema creation from data.script, my application starts working normally again.

Anyone having an idea/pointer where I could continue to look for the problem?

I think it's strange that the additional schema creation was written on top of the data.script file - I'd have assumed that lines are only appended to that file.

Any help would be appreciated.

I already tried to start two instances of my application at the same time to provoke a race condition. Also searched HSQLDB bug tracker and stackoverflow for similar issues. I found this question, but there it was a persistent and not a sporadic problem: Java JPA/Hibernate generates database schema twice

0

There are 0 best solutions below