You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2022/02/18 02:58:39 UTC
[GitHub] [servicecomb-java-chassis] jr981008 opened a new issue #2723: thread dead lock when use asyncresttmplate
jr981008 opened a new issue #2723:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2723
when code like this:
` ListenableFuture<ResponseEntity<String>> future = asyncRestTemplate.postForEntity("cse://xx/a/t",
new HttpEntity<String>(""), String.class);
future.addCallback(new ListenableFutureCallback<ResponseEntity<String>>() {
@Override
public void onFailure(Throwable e) {
e.printStackTrace();
}
@Override
public void onSuccess(ResponseEntity<String> v) {
try{
System.out.println(restTemplate.getForObject("cse://xx/a/t1", String.class));
}catch (Throwable e){
e.printStackTrace();
}
}`
High probability(5% 100tps) vertx eventloop deadlock:
stacktrace
2022-02-17 21:04:22 944[WARN][BlockedThreadChecker.java-63][vertx-blocked-thread-checker]-Thread Thread[vert.x-eventloop-thread-3,5,main]=Thread[vert.x-eventloop-thread-3,5,main] has been blocked for 202069 ms, time limit is 2000 ms
io.vertx.core.VertxException: Thread blocked
at sun.misc.Unsafe.park(Native Method)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:997)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1304)
at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:231)
at org.apache.servicecomb.core.provider.consumer.SyncResponseExecutor.waitResponse(SyncResponseExecutor.java:53)
at org.apache.servicecomb.core.provider.consumer.InvokerUtils.innerSyncInvoke(InvokerUtils.java:86)
at org.apache.servicecomb.provider.springmvc.reference.CseClientHttpRequest.doInvoke(CseClientHttpRequest.java:211)
at org.apache.servicecomb.provider.springmvc.reference.CseClientHttpRequest.invoke(CseClientHttpRequest.java:201)
at org.apache.servicecomb.provider.springmvc.reference.CseClientHttpRequest.execute(CseClientHttpRequest.java:152)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:737)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:672)
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:313)
check code:
syncresttmplate use countdownlatch wait in 200 threadspool,but asyncresttemplate use vertx eventloop forcallback,so when useing a syncrequest in asycnrequest callback ,vertx may dispatch request or result in the same eventloop thread ,if happen,this thread will dead lock forever,not timeout and other way to recover.
i dont see any warn about the way use like these.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #2723: thread dead lock when use asyncresttmplate
Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #2723:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2723#issuecomment-1043955890
使用异步的时候,不能在onSuccess逻辑里面使用同步调用。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org