Skip to content

H2 database seems to destroy some tables after a while #8331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ge0ffrey opened this issue Mar 19, 2020 · 21 comments
Closed

H2 database seems to destroy some tables after a while #8331

ge0ffrey opened this issue Mar 19, 2020 · 21 comments
Labels
area/persistence OBSOLETE, DO NOT USE kind/bug Something isn't working triage/out-of-date This issue/PR is no longer valid or relevant

Comments

@ge0ffrey
Copy link
Contributor

How to reproduce:

  1. Run "mvn compile quarkus:dev" for optaplanner-quickstart
  2. Open localhost:8080, everything is fine.
  3. Refresh, everything is fine.
  4. Wait 30 minutes. Maybe 10 minutes is enough. Refresh, get the error below.
2020-03-19 10:18:01,771 INFO  [io.quarkus] (main) optaplanner-quickstart 1.0-SNAPSHOT (powered by Quarkus 999-SNAPSHOT) started in 2.662s. Listening on: http://0.0.0.0:8080
2020-03-19 10:18:01,771 INFO  [io.quarkus] (main) Profile dev activated. Live Coding activated.
2020-03-19 10:18:01,772 INFO  [io.quarkus] (main) Installed features: [agroal, cdi, hibernate-orm, hibernate-orm-panache, jdbc-h2, narayana-jta, optaplanner, optaplanner-jackson, resteasy, resteasy-jackson]
2020-03-19 11:06:07,147 WARN  [org.hib.eng.jdb.spi.SqlExceptionHelper] (executor-thread-1) SQL Error: 42102, SQLState: 42S02
2020-03-19 11:06:07,148 ERROR [org.hib.eng.jdb.spi.SqlExceptionHelper] (executor-thread-1) Table "TIMESLOT" not found; SQL statement:
select timeslot0_.id as id1_2_, timeslot0_.dayOfWeek as dayofwee2_2_, timeslot0_.endTime as endtime3_2_, timeslot0_.startTime as starttim4_2_ from Timeslot timeslot0_ order by timeslot0_.dayOfWeek, timeslot0_.startTime, timeslot0_.endTime, timeslot0_.id limit ? [42102-197]
2020-03-19 11:06:07,152 WARN  [io.agr.pool] (executor-thread-1) Datasource '<default>': Closing open connection prior to rollback
2020-03-19 11:06:07,161 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-1) HTTP Request to /timeTable failed, error id: 5a0dcefb-f889-4385-b5b9-419931fb4575-1: org.jboss.resteasy.spi.UnhandledException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not prepare statement
        at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:106)
        at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:372)
        at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:216)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:515)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:259)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:160)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:362)
        at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:163)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:245)
        at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:122)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.access$000(VertxRequestHandler.java:36)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:87)
        at io.quarkus.runtime.CleanableExecutor$CleaningRunnable.run(CleanableExecutor.java:231)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2027)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1551)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1442)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
        at java.lang.Thread.run(Thread.java:748)
        at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not prepare statement
        at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)
        at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1539)
        at org.hibernate.query.Query.getResultList(Query.java:165)
        at io.quarkus.hibernate.orm.panache.runtime.PanacheQueryImpl.list(PanacheQueryImpl.java:137)
        at io.quarkus.hibernate.orm.panache.runtime.JpaOperations.listAll(JpaOperations.java:347)
        at org.acme.optaplanner.domain.Timeslot.listAll(Timeslot.java)
        at org.acme.optaplanner.rest.TimeTableResource.findById(TimeTableResource.java:72)
        at org.acme.optaplanner.rest.TimeTableResource_Subclass.findById$$superaccessor11(TimeTableResource_Subclass.zig:22)
        at org.acme.optaplanner.rest.TimeTableResource_Subclass$$function$$11.apply(TimeTableResource_Subclass$$function$$11.zig:33)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:119)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:92)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.doIntercept(TransactionalInterceptorRequired.java:32)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.intercept(TransactionalInterceptorBase.java:53)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.intercept(TransactionalInterceptorRequired.java:26)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired_Bean.intercept(TransactionalInterceptorRequired_Bean.zig:168)
        at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
        at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
        at org.acme.optaplanner.rest.TimeTableResource_Subclass.findById(TimeTableResource_Subclass.zig:92)
        at org.acme.optaplanner.rest.TimeTableResource.getTimeTable(TimeTableResource.java:40)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
        at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:621)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:487)
        at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:437)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:362)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:439)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:400)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:374)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:67)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:488)
        ... 20 more
Caused by: org.hibernate.exception.SQLGrammarException: could not prepare statement
        at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:103)
        at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
        at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:186)
        at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151)
        at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104)
        at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2034)
        at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2012)
        at org.hibernate.loader.Loader.doQuery(Loader.java:953)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:354)
        at org.hibernate.loader.Loader.doList(Loader.java:2838)
        at org.hibernate.loader.Loader.doList(Loader.java:2820)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2652)
        at org.hibernate.loader.Loader.list(Loader.java:2647)
        at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506)
        at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:396)
        at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219)
        at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1404)
        at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1562)
        at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1530)
        ... 54 more
Caused by: org.h2.jdbc.JdbcSQLException: Table "TIMESLOT" not found; SQL statement:
select timeslot0_.id as id1_2_, timeslot0_.dayOfWeek as dayofwee2_2_, timeslot0_.endTime as endtime3_2_, timeslot0_.startTime as starttim4_2_ from Timeslot timeslot0_ order by timeslot0_.dayOfWeek, timeslot0_.startTime, timeslot0_.endTime, timeslot0_.id limit ? [42102-197]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
        at org.h2.message.DbException.get(DbException.java:179)
        at org.h2.message.DbException.get(DbException.java:155)
        at org.h2.command.Parser.readTableOrView(Parser.java:5920)
        at org.h2.command.Parser.readTableFilter(Parser.java:1430)
        at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:2138)
        at org.h2.command.Parser.parseSelectSimple(Parser.java:2287)
        at org.h2.command.Parser.parseSelectSub(Parser.java:2133)
        at org.h2.command.Parser.parseSelectUnion(Parser.java:1946)
        at org.h2.command.Parser.parseSelect(Parser.java:1919)
        at org.h2.command.Parser.parsePrepared(Parser.java:463)
        at org.h2.command.Parser.parse(Parser.java:335)
        at org.h2.command.Parser.parse(Parser.java:307)
        at org.h2.command.Parser.prepareCommand(Parser.java:278)
        at org.h2.engine.Session.prepareLocal(Session.java:611)
        at org.h2.engine.Session.prepareCommand(Session.java:549)
        at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1247)
        at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:76)
        at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:304)
        at io.agroal.pool.wrapper.ConnectionWrapper.prepareStatement(ConnectionWrapper.java:605)
        at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149)
        at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176)
        ... 70 more

2020-03-19 11:06:10,150 WARN  [org.hib.eng.jdb.spi.SqlExceptionHelper] (executor-thread-1) SQL Error: 42102, SQLState: 42S02
2020-03-19 11:06:10,150 ERROR [org.hib.eng.jdb.spi.SqlExceptionHelper] (executor-thread-1) Table "TIMESLOT" not found; SQL statement:
select timeslot0_.id as id1_2_, timeslot0_.dayOfWeek as dayofwee2_2_, timeslot0_.endTime as endtime3_2_, timeslot0_.startTime as starttim4_2_ from Timeslot timeslot0_ order by timeslot0_.dayOfWeek, timeslot0_.startTime, timeslot0_.endTime, timeslot0_.id limit ? [42102-197]
2020-03-19 11:06:10,150 WARN  [io.agr.pool] (executor-thread-1) Datasource '<default>': Closing open connection prior to rollback
2020-03-19 11:06:10,152 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-1) HTTP Request to /timeTable failed, error id: 5a0dcefb-f889-4385-b5b9-419931fb4575-2: org.jboss.resteasy.spi.UnhandledException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not prepare statement
        at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:106)
        at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:372)
        at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:216)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:515)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:259)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:160)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:362)
        at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:163)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:245)
        at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:122)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.access$000(VertxRequestHandler.java:36)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:87)
        at io.quarkus.runtime.CleanableExecutor$CleaningRunnable.run(CleanableExecutor.java:231)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2027)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1551)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1442)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
        at java.lang.Thread.run(Thread.java:748)
        at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not prepare statement
        at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)
        at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1539)
        at org.hibernate.query.Query.getResultList(Query.java:165)
        at io.quarkus.hibernate.orm.panache.runtime.PanacheQueryImpl.list(PanacheQueryImpl.java:137)
        at io.quarkus.hibernate.orm.panache.runtime.JpaOperations.listAll(JpaOperations.java:347)
        at org.acme.optaplanner.domain.Timeslot.listAll(Timeslot.java)
        at org.acme.optaplanner.rest.TimeTableResource.findById(TimeTableResource.java:72)
        at org.acme.optaplanner.rest.TimeTableResource_Subclass.findById$$superaccessor11(TimeTableResource_Subclass.zig:22)
        at org.acme.optaplanner.rest.TimeTableResource_Subclass$$function$$11.apply(TimeTableResource_Subclass$$function$$11.zig:33)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:119)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:92)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.doIntercept(TransactionalInterceptorRequired.java:32)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.intercept(TransactionalInterceptorBase.java:53)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.intercept(TransactionalInterceptorRequired.java:26)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired_Bean.intercept(TransactionalInterceptorRequired_Bean.zig:168)
        at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
        at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
        at org.acme.optaplanner.rest.TimeTableResource_Subclass.findById(TimeTableResource_Subclass.zig:92)
        at org.acme.optaplanner.rest.TimeTableResource.getTimeTable(TimeTableResource.java:40)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
        at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:621)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:487)
        at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:437)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:362)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:439)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:400)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:374)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:67)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:488)
        ... 20 more
Caused by: org.hibernate.exception.SQLGrammarException: could not prepare statement
        at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:103)
        at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
        at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:186)
        at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151)
        at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104)
        at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2034)
        at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2012)
        at org.hibernate.loader.Loader.doQuery(Loader.java:953)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:354)
        at org.hibernate.loader.Loader.doList(Loader.java:2838)
        at org.hibernate.loader.Loader.doList(Loader.java:2820)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2652)
        at org.hibernate.loader.Loader.list(Loader.java:2647)
        at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506)
        at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:396)
        at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219)
        at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1404)
        at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1562)
        at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1530)
        ... 54 more
Caused by: org.h2.jdbc.JdbcSQLException: Table "TIMESLOT" not found; SQL statement:
select timeslot0_.id as id1_2_, timeslot0_.dayOfWeek as dayofwee2_2_, timeslot0_.endTime as endtime3_2_, timeslot0_.startTime as starttim4_2_ from Timeslot timeslot0_ order by timeslot0_.dayOfWeek, timeslot0_.startTime, timeslot0_.endTime, timeslot0_.id limit ? [42102-197]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
        at org.h2.message.DbException.get(DbException.java:179)
        at org.h2.message.DbException.get(DbException.java:155)
        at org.h2.command.Parser.readTableOrView(Parser.java:5920)
        at org.h2.command.Parser.readTableFilter(Parser.java:1430)
        at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:2138)
        at org.h2.command.Parser.parseSelectSimple(Parser.java:2287)
        at org.h2.command.Parser.parseSelectSub(Parser.java:2133)
        at org.h2.command.Parser.parseSelectUnion(Parser.java:1946)
        at org.h2.command.Parser.parseSelect(Parser.java:1919)
        at org.h2.command.Parser.parsePrepared(Parser.java:463)
        at org.h2.command.Parser.parse(Parser.java:335)
        at org.h2.command.Parser.parse(Parser.java:307)
        at org.h2.command.Parser.prepareCommand(Parser.java:278)
        at org.h2.engine.Session.prepareLocal(Session.java:611)
        at org.h2.engine.Session.prepareCommand(Session.java:549)
        at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1247)
        at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:76)
        at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:304)
        at io.agroal.pool.wrapper.ConnectionWrapper.prepareStatement(ConnectionWrapper.java:605)
        at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149)
        at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176)
        ... 70 more
@ge0ffrey
Copy link
Contributor Author

@Sanne Could this be a bug in Hibernate, H2 or the quarkus code around these components?

@ge0ffrey
Copy link
Contributor Author

It does reproduce consistently. It's a great way to force me to avoid checking corona news :)

2020-03-19 11:12:23,544 INFO  [io.quarkus] (main) Installed features: [agroal, cdi, hibernate-orm, hibernate-orm-panache, jdbc-h2, narayana-jta, optaplanner, optaplanner-jackson, resteasy, resteasy-jackson]
2020-03-19 11:41:04,927 WARN  [org.hib.eng.jdb.spi.SqlExceptionHelper] (executor-thread-1) SQL Error: 42102, SQLState: 42S02
...
``

@Sanne
Copy link
Member

Sanne commented Mar 19, 2020

Hi @ge0ffrey ! Interesting, I don't know what could be the cause. Hibernate certainly doesn't drop tables - unless it's being restarted for some reason and configured to drop tables on boot, but even then it would re-create them. FWIW, Hibernate doesn't have any timer so this is likely triggered by some other component.

Also you might want to consider that we don't generally support using H2 in embedded mode: this won't work in native-image. Please check the suggestions I've added on https://quarkus.io/guides/datasource#in-memory-databases

@Sanne
Copy link
Member

Sanne commented Mar 19, 2020

It's a great way to force me to avoid checking corona news :)

you're welcome, enjoy! 😄

@ge0ffrey
Copy link
Contributor Author

@Sanne I still prefer to use the H2 in embedded mode for non-native runs, to lower the barrier to entry: mvn compile quarkus:dev just works, without jumping through any hoops to set up a Database server first. Just like the Spring examples. That's a much better Getting Started Experience.

@ge0ffrey
Copy link
Contributor Author

ge0ffrey commented Apr 1, 2020

Guys, there's clearly a bug here in Quarkus when using H2 embedded with Hotspot.
It's easy to reproduce and serious (see PR description). It's unclear what component is causing it.
@ia3andy @Sanne What's the process to make progress on this issue? Or are we closing it as "won't fix"?

@Sanne
Copy link
Member

Sanne commented Apr 1, 2020

There's no need to close it @ge0ffrey , and I've not rejected it either - but I'm considering this low priority (especially as it's not being used like we suggest) and need to focus on other issues first. So let's just leave it here?

There's also the possibility that it could be an H2 bug - we don't maintain the database.

Someone would need to find some time to figure out what's going on in more detail.

@ge0ffrey
Copy link
Contributor Author

ge0ffrey commented Apr 1, 2020

Thanks @Sanne - makes sense - is there a label / assignee to mark it as being in the hibernate's team backlog (or in yours personally)?

@Sanne Sanne changed the title optaplanner-quickstart: hibernate crashes in quarkus:dev mode if unused for a while H2 database seems to destroy some tables after a while Apr 1, 2020
@Sanne
Copy link
Member

Sanne commented Apr 1, 2020

ah, I see the source of confusion now: we should transfer this bug to Quarkus, you've opened it on the quickstarts. We have better labels and overview in the main repository.

@Sanne Sanne transferred this issue from quarkusio/quarkus-quickstarts Apr 1, 2020
@Sanne Sanne added area/persistence OBSOLETE, DO NOT USE kind/bug Something isn't working labels Apr 1, 2020
@ge0ffrey
Copy link
Contributor Author

ge0ffrey commented Apr 1, 2020

Thanks!

@famod
Copy link
Member

famod commented Apr 2, 2020

H2 in Quarkus seems to be pinned to 1.4.197 because of this: #1522
Back then 1.4.200 was not yet available so maybe that might be worth a try?
The changelog is rather long: https://h2database.com/html/changelog.html

@stuartwdouglas
Copy link
Member

Can you add ;DB_CLOSE_DELAY=-1 to the connection URL?

According to the h2 docs the in memory DB will be closed after the last connection is closed, and agroal with its default config will time out connections after 5m.

http://www.h2database.com/html/features.html

@ge0ffrey
Copy link
Contributor Author

ge0ffrey commented Apr 8, 2020

I'll try that. I'll also check if this issue reproduces with the spring-boot exmaple for optaplanner which also uses H2.

@famod
Copy link
Member

famod commented May 15, 2020

@ge0ffrey Any update? Thanks!

Btw, I created #9354 regarding the update of h2.

@stuartwdouglas
Copy link
Member

@ge0ffrey I am closing, as I am pretty sure the issue was the timeout that I described above.

@stuartwdouglas stuartwdouglas added the triage/out-of-date This issue/PR is no longer valid or relevant label Jul 8, 2020
@alexander-dammeier
Copy link

We have the same problem while using dual dev mode with quarkus and angular. I added ;DB_CLOSE_DELAY=-1 to our connection url and now it works! It think this should be documented somewhere so everybody finds that before this issue occurs again.

Background:
We are developing a software using event sourcing. In production we are using postgres and in dev-mode we are using H2. There is only one Table in our DB and no complex SQL-Statements so there is no reason for us to use a real postgres DB in dev-mode. For this reason an In-Memory-DB like H2 saves us a lot of unnecessary overhead in our development cycle.

@stuartwdouglas
Copy link
Member

It's in the H2 documentation. Maybe we could add some special case code around but I am not really sure what would be the best approach

@gsmet
Copy link
Member

gsmet commented Aug 3, 2020

We have this notion of AgroalConnectionConfigurer that can tweak the connection.

We could add a new method there that would be called if we are in dev mode and contribute the additional parameter?

@stuartwdouglas
Copy link
Member

I don't think it needs to be dev mode specific.

Also setting the min size to 1 rather than 0 would do it, which may be a simpler approach.

@ge0ffrey
Copy link
Contributor Author

ge0ffrey commented Aug 4, 2020 via email

@ge0ffrey
Copy link
Contributor Author

ge0ffrey commented Aug 4, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/persistence OBSOLETE, DO NOT USE kind/bug Something isn't working triage/out-of-date This issue/PR is no longer valid or relevant
Projects
None yet
Development

No branches or pull requests

6 participants