-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Description
Spring Boot 2.3.1
I've been playing around with the latest Spring Boot Graceful Shutdown feature and discovered that after adding spring-cloud-config-server
, as a dependency, my Spring Boot application fails to use configured spring.lifecycle.timeout-per-shutdown-phase
property and, instead, it's using the default 30s value for graceful shutdown timeout.
I've prepared a minimal application:
https://github.com/pszemus/graceful-shutdown-demo
that has configured graceful shutdown timeout of 8s: https://github.com/pszemus/graceful-shutdown-demo/blob/master/src/main/resources/application.yml#L5
After requesting the long lasting endpoint /greeting
and stoping the application it should stop after 8 seconds, but it's stopping after 30 seconds, instead:
2020-06-18 16:02:59.629 INFO 31481 --- [extShutdownHook] o.s.b.w.e.tomcat.GracefulShutdown : Commencing graceful shutdown. Waiting for active requests to complete
2020-06-18 16:03:29.631 INFO 31481 --- [extShutdownHook] o.s.c.support.DefaultLifecycleProcessor : Failed to shut down 1 bean with phase value 2147483647 within timeout of 30000ms: [webServerGracefulShutdown]
2020-06-18 16:03:29.680 INFO 31481 --- [tomcat-shutdown] o.s.b.w.e.tomcat.GracefulShutdown : Graceful shutdown aborted with one or more requests still active
Configured 8 seconds timeout is visible in /actuator/configprops
, but apparently it's not used:
"spring.lifecycle-org.springframework.boot.autoconfigure.context.LifecycleProperties": {
"prefix": "spring.lifecycle",
"properties": {
"timeoutPerShutdownPhase": "PT8S"
},
"inputs": {
"timeoutPerShutdownPhase": {
"origin": "class path resource [application.yml]:5:37",
"value": "8s"
}
}
}
If one gets rid of spring-cloud-config-server
from pom.xml: https://github.com/pszemus/graceful-shutdown-demo/blob/master/pom.xml#L22
then the application starts using configured 8s timeout:
C2020-06-18 15:54:13.934 INFO 30672 --- [extShutdownHook] o.s.b.w.e.tomcat.GracefulShutdown : Commencing graceful shutdown. Waiting for active requests to complete
2020-06-18 15:54:21.937 INFO 30672 --- [extShutdownHook] o.s.c.support.DefaultLifecycleProcessor : Failed to shut down 1 bean with phase value 2147483647 within timeout of 8000ms: [webServerGracefulShutdown]
2020-06-18 15:54:21.983 INFO 30672 --- [tomcat-shutdown] o.s.b.w.e.tomcat.GracefulShutdown : Graceful shutdown aborted with one or more requests still active