Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shutting down ExecutorService 'applicationTaskExecutor'

I have a Spring-boot application deployed in docker container within in AWS ECS cluster.

My application stack is => Spring Boot -- JPA -- MySQL RDS

Initially application is deployed and accessible through EC2 public IP.

But after few minutes only application is Shutting down ExecutorService 'applicationTaskExecutor' and restart container again. it is happening constantly in every 3/4 mins.

I am not getting this kind of error in local deployment connecting to same RDS.

Here is my application.properties

server.port=8192

spring.datasource.url=jdbc:mysql://multichannelappdatabase.cvjsdfsdfsdfsfs.us-east-1.rds.amazonaws.com:3306/multichannelappdb
spring.datasource.username=xxxxx
spring.datasource.password=xxxxx
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver


spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false

spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
spring.jpa.show-sql=true
#spring.jpa.hibernate.ddl-auto=create
spring.datasource.testWhileIdle = true
spring.datasource.timeBetweenEvictionRunsMillis = 10000
spring.datasource.tomcat.testOnBorrow=true 
spring.datasource.tomcat.validationQuery=SELECT 1

and here is my cloudwatch log


16:20:50
2019-05-02 16:20:50.514 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8192 (http) with context path ''

16:20:50
2019-05-02 16:20:50.516 INFO 1 --- [ main] c.api.app.runner.UserManagerApplication : Started UserManagerApplication in 9.338 seconds (JVM running for 10.291)

16:20:57
2019-05-02 16:20:57.117 INFO 1 --- [nio-8192-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'

16:20:57
2019-05-02 16:20:57.117 INFO 1 --- [nio-8192-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'

16:20:57
2019-05-02 16:20:57.131 INFO 1 --- [nio-8192-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 14 ms

16:23:19
2019-05-02 16:23:19.253 INFO 1 --- [ Thread-4] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'

16:23:19
2019-05-02 16:23:19.254 INFO 1 --- [ Thread-4] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'

16:23:19
2019-05-02 16:23:19.257 INFO 1 --- [ Thread-4] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...

16:23:19
2019-05-02 16:23:19.274 INFO 1 --- [ Thread-4] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.

Need suggestion to resolve this issue.

Still getting the same issue .. any solution will be helpful

like image 639
ajoy sinha Avatar asked May 02 '19 16:05

ajoy sinha


People also ask

How do you shut down an ExecutorService?

To properly shut down an ExecutorService, we have the shutdown() and shutdownNow() APIs. The shutdown() method doesn't cause immediate destruction of the ExecutorService. It will make the ExecutorService stop accepting new tasks and shut down after all running threads finish their current work: executorService.

Is it necessary to shutdown ExecutorService?

When finished using an ExecutorService , you need to shut it down explicitly. From its javadoc: "An unused ExecutorService should be shut down to allow reclamation of its resources." Calling shutdown initiates a gradual and orderly shutdown.

Why spring boot is shutting down?

We know that a Spring Boot web app needs an embedded servlet container on the classpath. The app will shut down if it doesn't find any of the embedded servlet containers. To resolve the unexpected shut down during startup, we need to obtain a fully configured instance using the appropriate Starter.


Video Answer


1 Answers

I had a similar symptom, the problem was solved for me by resolving the liveliness and readiness checks.

like image 147
ankit_kurani Avatar answered Sep 19 '22 15:09

ankit_kurani