reactor / reactor-core

Non-Blocking Reactive Foundation for the JVM
http://projectreactor.io
Apache License 2.0
4.99k stars 1.21k forks source link

Jetty threads getting blocked in response timeout testing causing application crash #3922

Closed owaiscs001 closed 4 days ago

owaiscs001 commented 2 weeks ago

Description I'm testing a traffic scenario with TPS of ~1000, the HTTP/2 server has a high delay hence all the message send by Jetty HTTP/2 client to the server gets timed out. Below is my observation with this run.

Request: I encountered an uncaught exception in the system, and I'm reaching out for clarification on the underlying cause. The stacktrace attached below shows the thread is blocked while attempting to acquire a lock on the PrintStream object. Could you help clarify what might be causing this blockage? Is there a specific condition or known issue that could lead to this uncaught exception?

Root Cause Analysis: Are there any tools or methods to help identify the reasons behind the thread blocking?

Additional Information: Stacktrace of the blocked threads

`"@365a6a43-35" #35 prio=5 os_prio=0 cpu=28.09ms elapsed=689.64s tid=0x00007f9741f42d20 nid=0x3e waiting for monitor entry [0x00007f970c8fa000] java.lang.Thread.State: BLOCKED (on object monitor) at java.io.PrintStream.write(java.base@17.0.7/PrintStream.java:695)

Your Environment

chemicL commented 4 days ago

Hi,

I have a couple points:

  1. BlockHound can be used to track blocking calls.
  2. From the stacktrace - an onError is triggered and it struggles to delegate to a provided Scheduler based on a wrapped Executor. That Executor has a Thread that's within a ThreadGroup, which has a defined uncaughtExceptionHandler. My guess is that the actual handler is Schedulers.defaultUncaughtException, which delegates to slf4j to log the issue. It looks as if in this case you're using a blocking slf4j backend - perhaps Logback's ConsoleAppender or something of that sort? If that's the case it's best to wrap it with an AsyncAppender or an equivalent in a different implementation.
  3. reactor-core 3.4 is out of open-source support, please consider upgrading.
  4. We don't maintain the Jetty HttpClient, perhaps it's worth reaching out in the respective repository if you end up discovering an issue is caused by its implementation.

In case there's a genuine issue in reactor-core, please reopen with a relevant reproducer. Good luck on your quest to uncover the issue! :)