apache / apache/dubbo

[Bug] application shutdown report error:java.lang.IllegalStateException: Shutdown in progress

Open
#14,429 3 comments 0 reactions 0 assignees View on GitHub
component/need-triage type/need-triage
Dominant language
Java
Stars
41.6k
Forks
26.4k
Avg merge
15h 13m
Merged PRs (30d)
4

Description

### Pre-check

- [X] I am sure that all the content I provide is in English.

### Search before asking

- [X] I had searched in the [issues](https://github.com/apache/dubbo/issues?q=is%3Aissue) and found no similar issues.

### Apache Dubbo Component

Java SDK (apache/dubbo)

### Dubbo Version

Dubbo Java 3.2.14, JDK 17

### Steps to reproduce this issue

When shutdown dubbo spring-boot application, some times report this error:
```
2024-07-12 01:00:39.369 WARN [SpringApplicationShutdownHook] o.a.d.common.logger.log4j2.Log4j2Logger#warn(L:86) -> [DUBBO] unregister shutdown hook failed: Shutdown in progress, dubbo version: 3.2.14, current host: 172.18.0.15, error code: 5-2. This may be caused by , go to https://dubbo.apache.org/faq/5/2 to find instructions.
java.lang.IllegalStateException: Shutdown in progress
at java.base/java.lang.ApplicationShutdownHooks.remove(Unknown Source) ~[?:?]
at java.base/java.lang.Runtime.removeShutdownHook(Unknown Source) ~[?:?]
at org.apache.dubbo.config.DubboShutdownHook.unregister(DubboShutdownHook.java:171) ~[dubbo-3.2.14.jar!/:3.2.14]
at org.apache.dubbo.config.deploy.DefaultApplicationDeployer.unRegisterShutdownHook(DefaultApplicationDeployer.java:182) ~[dubbo-3.2.14.jar!/:3.2.14]
at org.apache.dubbo.config.deploy.DefaultApplicationDeployer.preDestroy(DefaultApplicationDeployer.java:1063) ~[dubbo-3.2.14.jar!/:3.2.14]
at org.apache.dubbo.rpc.model.ApplicationModel.onDestroy(ApplicationModel.java:155) ~[dubbo-3.2.14.jar!/:3.2.14]
at org.apache.dubbo.rpc.model.ScopeModel.destroy(ScopeModel.java:122) ~[dubbo-3.2.14.jar!/:3.2.14]
at org.apache.dubbo.rpc.model.ApplicationModel.tryDestroy(ApplicationModel.java:276) ~[dubbo-3.2.14.jar!/:3.2.14]
at org.apache.dubbo.rpc.model.ModuleModel.onDestroy(ModuleModel.java:133) ~[dubbo-3.2.14.jar!/:3.2.14]
at org.apache.dubbo.rpc.model.ScopeModel.destroy(ScopeModel.java:122) ~[dubbo-3.2.14.jar!/:3.2.14]
at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onContextClosedEvent(DubboDeployApplicationListener.java:189) ~[dubbo-3.2.14.jar!/:3.2.14]
at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:145) ~[dubbo-3.2.14.jar!/:3.2.14]
at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:52) ~[dubbo-3.2.14.jar!/:3.2.14]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:185) ~[spring-context-6.1.10.jar!/:6.1.10]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:178) ~[spring-context-6.1.10.jar!/:6.1.10]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:156) ~[spring-context-6.1.10.jar!/:6.1.10]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:451) ~[spring-context-6.1.10.jar!/:6.1.10]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:384) ~[spring-context-6.1.10.jar!/:6.1.10]
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1130) ~[spring-context-6.1.10.jar!/:6.1.10]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.doClose(ServletWebServerApplicationContext.java:174) ~[spring-boot-3.2.7.jar!/:3.2.7]
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1093) ~[spring-context-6.1.10.jar!/:6.1.10]
at org.springframework.boot.SpringApplicationShutdownHook.closeAndWait(SpringApplicationShutdownHook.java:145) ~[spring-boot-3.2.7.jar!/:3.2.7]
at java.base/java.lang.Iterable.forEach(Unknown Source) ~[?:?]
at org.springframework.boot.SpringApplicationShutdownHook.run(SpringApplicationShutdownHook.java:114) ~[spring-boot-3.2.7.jar!/:3.2.7]
at java.base/java.lang.Thread.run(Unknown Source) [?:?]
```

### What you expected to happen

don't report error

### Anything else

_No response_

### Are you willing to submit a pull request to fix on your own?

- [ ] Yes I am willing to submit a pull request on my own!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)

Contributor guide

Open the contributing guide

Research direction

Start with DubboShutdownHook.unregister and DefaultApplicationDeployer.preDestroy, then follow the SpringApplicationShutdownHook and DubboDeployApplicationListener shutdown path shown in the stack trace. Reproduce application shutdown with Dubbo 3.2.14 on JDK 17 and verify that the shutdown completes without reporting the IllegalStateException or the unregister-shutdown-hook warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.