A very weird situation. I am using Spring Boot with Spring Data JPA and MySQL running in a docker container. After starting the application all works fine (the DB is initialized upon startup with spring.jpa.hibernate.ddl-auto=create-drop
).
If I leave the app running, after ~10 minutes, when running another request, I get back table doesn't exist
. Checking the DB, I can see all the tables are gone (the schema is still there)!
Logs show me this WARN right before the error:
2020-12-20 16:15:41.151 WARN 11018 --- [nio-8080-exec-4] com.zaxxer.hikari.pool.PoolBase : myDS - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@67dd33b2 (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.
2020-12-20 16:15:41.153 WARN 11018 --- [nio-8080-exec-4] com.zaxxer.hikari.pool.PoolBase : myDS - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@3817c06d (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.
2020-12-20 16:15:41.155 WARN 11018 --- [nio-8080-exec-4] com.zaxxer.hikari.pool.PoolBase : myDS - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@536cd1b2 (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.
And then:
2020-12-20 16:15:41.161 WARN 11018 --- [nio-8080-exec-4] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 1146, SQLState: 42S02
2020-12-20 16:15:41.161 ERROR 11018 --- [nio-8080-exec-4] o.h.engine.jdbc.spi.SqlExceptionHelper : Table 'tasker.account' doesn't exist
2020-12-20 16:15:41.173 INFO 11018 --- [nio-8080-exec-4] o.h.e.internal.DefaultLoadEventListener : HHH000327: Error performing load command
I've also added this setting in application.properties:
spring.datasource.hikari.max-lifetime=600000
to match mysql's settings.
Docker is started with:
docker run --name=mysql1 --restart on-failure -d mysql/mysql-server:8.0
Note: This never happens with local instance of mysql (native, not in docker)
Any help would be appreciated.