Describe the bug I use tomcat as servlet container in springboot, and use eureka-server as the naming service. the version is : spring-boot-2.0.3.RELEASE and spring-boot-2.5.?.RELEASE I notice that when I turn on tomcat's min-spare-threads to a big number, see 100, I'll get many error requests when I restart the application. (in our production env)
Then I check the code inside and find that, spring application registers to naming-service before it starts tomcat server(start the worker and accepter threads), that is to say, the application may be available(to other eureka clients) before tomcat gets ready. Which confuse me ver much, why not start tomcat first?(when tomcat start, it will created minSpareThreads to its threadPool) Is there any reason?
Sample
first start a eureka-server:
you can see these is no instances currently
then add a break point here:
the path is : spring-boot-2.0.3.RELEASE-sources.jar!/org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext#finishRefresh
then debug the application and we stop here:
from the console, you can see that this application has registered to eureka-server.
now we can find this in currently instances
But in fact, we cannot visit this application cause its servlet container is not ready:
so I think it's a bug, application should not register to eureka-server before it's ready.
Comment From: spencergibb
Those versions are no longer supported. Please try again with boot 2.7/spring cloud 2021.0.5 or boot 3.0/cloud 2022.0.1
Comment From: spring-cloud-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: Melon-Seeds
I apologize for my recent lack of communication. I've been quite busy due to personal matters such as being let go from my previous job, job hunting, and adjusting to a new work schedule and company culture. Moving forward, I wanted to discuss the topic at hand. I have tried the new version you mentioned (Spring 2.7.9) and am happy to report that the issue I previously mentioned has been resolved. Attached are some screenshots from my testing.
Brekpoint:
eureka-client-1.10.17-sources.jar!\com\netflix\discovery\DiscoveryClient.java
Version:
erueka-console
Servlet-container
Finally, thanks for your reply!
Comment From: spencergibb
Thanks for the update
Comment From: Yunie9
Thanks for the update
However, I noticed that in the spring-cloud-netflix-eureka-client-3.1.4 source, EurekaAutoServiceRegistration's getPhase method returns 0, Less than WebServerStartStopLifecycle's getPhase method return value (Integer. MAX_VALUE - 1). This means that in some extreme cases, it is indeed possible for a service to register with eureka before it's serviceable.