spring-cloud-commons icon indicating copy to clipboard operation
spring-cloud-commons copied to clipboard

Occasionally, deadlocks occur when the main thread and asynchronous thread initialize the same Feign Api call

Open dongfangding opened this issue 1 year ago • 4 comments

When I initiate a remote call for initialization using a Feign API in the main thread, and perform similar operations using the same Feign API in an asynchronous thread in the initialization of another class. I am following org.springframework.cloud.context.named.NamedContextFactory#getContext obtains the lock, there will be a call to the context.refresh(), which in turn will contain another lock. At certain times, due to uncontrollable sequence, the main thread may experience a deadlock and fail to start.

Sample

@Component
Class A {
   @PostConstruct
   public void init() {
       // Feign Api remote call
   }
}

@Component
Class B {
   @PostConstruct
   public void init() {
       Executors.newSingleThreadExecutor().execute(() -> {
             // Same feign API calls
       });
   }
}

dongfangding avatar May 16 '24 08:05 dongfangding

Hello @dongfangding, I was not able to reproduce it. Could you provide more details, such as a thread dump?

OlgaMaciaszek avatar Sep 27 '24 12:09 OlgaMaciaszek

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.

spring-cloud-issues avatar Oct 04 '24 12:10 spring-cloud-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

spring-cloud-issues avatar Oct 11 '24 12:10 spring-cloud-issues

image image

dongfangding avatar Oct 11 '24 15:10 dongfangding