Comments (7)
thanks for reporting, will take a look.
from blockhound.
I could reproduce using this sample project:
now, it seems that there are some BlockingOperationError exception that are happening but they are not logged.
For example, I have hacked the BlockHound BlockingOperationError
class like this:
public BlockingOperationError(BlockingMethod method) {
super(String.format("Blocking call! %s", method));
this.method = method;
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
this.printStackTrace(printWriter);
System.out.println("[" + Thread.currentThread().getName() + "] BlockingOperationError: " + stringWriter.toString());
}
then I can see a tons of exceptions like this:
[redisson-3-1] BlockingOperationError: reactor.blockhound.BlockingOperationError: Blocking call! jdk.internal.misc.Unsafe#park
at reactor.blockhound.BlockHound$Builder.lambda$new$0(BlockHound.java:260)
at reactor.blockhound.BlockHound$Builder.lambda$install$8(BlockHound.java:490)
at reactor.blockhound.BlockHoundRuntime.checkBlocking(BlockHoundRuntime.java:89)
at java.base/jdk.internal.misc.Unsafe.park(Unsafe.java)
at java.base/java.util.concurrent.locks.LockSupport.park(LockSupport.java:371)
at java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block(AbstractQueuedSynchronizer.java:519)
at java.base/java.util.concurrent.ForkJoinPool.unmanagedBlock(ForkJoinPool.java:3780)
at java.base/java.util.concurrent.ForkJoinPool.managedBlock(ForkJoinPool.java:3725)
at java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1707)
at java.base/java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:435)
at java.base/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1070)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:1583)
there is a permitBlockingCalls
method in FastThreadLocalThread which can be used to mark a FastThreadLocalThread so it can run blocking tasks, but I don't know what is exactly happening for the moment.
while trying to debug, I observed for example that RedisClient can schedule some FastThreadLocalRunnable tasks like in the following stacktrace:
java.lang.Exception: Stack trace
at java.base/java.lang.Thread.dumpStack(Thread.java:2209)
at io.netty.util.concurrent.FastThreadLocalRunnable.<init>(FastThreadLocalRunnable.java:24)
at io.netty.util.concurrent.FastThreadLocalRunnable.wrap(FastThreadLocalRunnable.java:38)
at io.netty.util.concurrent.DefaultThreadFactory.newThread(DefaultThreadFactory.java:105)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.<init>(ThreadPoolExecutor.java:637)
at java.base/java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:928)
at java.base/java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1364)
at org.redisson.client.RedisClient$1$1.run(RedisClient.java:288)
at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:31)
at java.base/java.lang.Thread.run(Thread.java:1583)
so, it looks like some blocking codes are scheduled in some netty FastThreadLocalThreads, which are assumed to be non blocking.
honestly, I'm not sure to understand everything here, but I cannot see any issues in BlockHound itself for the moment.
from blockhound.
I think I can skip blocking inside by
BlockHound.builder().allowBlockingCallsInside(Vertx.class.getName(), "executeBlocking").install()
,
but it seems to skip all blocking operations. Can you guide me how I can find the exactly class and methods to use allowBlockingCallsInside()
.
from blockhound.
I tried it like the following, but it does not seem to resolve the problem:
BlockHound.install(builder -> builder.allowBlockingCallsInside("io.vertx.core.Vertx", "executeBlocking"));
However, I tried this which works, but it's probably not a good idea to allow blocking calls from netty FastThreadLocalThread, maybe the following could be done with adding a flag in order to only allow blocking calls during the startup time ? The following allows all blocking calls from netty FastThreadLocalThread threads:
BlockHound.install(builder -> builder.nonBlockingThreadPredicate(p ->
thread -> thread instanceof FastThreadLocalThread ? false : p.test(thread)));
you can also do this, which allow blocking calls from any FastThreadLocalRunnable.run methods (but is it what should be done, I'm not sure):
BlockHound.install(builder -> builder.allowBlockingCallsInside("io.netty.util.concurrent.FastThreadLocalRunnable", "run"));
you can check (Dis-)allowing blocking calls inside methods
section from docs for more examples.
from blockhound.
I've hit the same issue and managed to work around it like so:
BlockHound.install(builder -> {
builder.nonBlockingThreadPredicate(p -> thread -> !thread.getName().contains("redisson") && p.test(thread));
});
from blockhound.
It seems to the Redisson does not support Reactive completely, so maybe allow Redisson call blocking inside.
@pderop the builder.nonBlockingThreadPredicate(..)
works for me.
But the builder.allowBlockingCallsInside(..)
does not work.
@draguljce I tried your code and it just passed the redisson
startup time. Because Redisson still call FastThreadLocalRunnable
in runtime.
from blockhound.
if you don't mind, I will close this issue, because for the moment I don't see any issues to fix in BlockHound itself.
but feel free to reopen, if it's necessary.
from blockhound.
Related Issues (20)
- `java.nio.channels.FileChannel` related operations are not detected as blocking
- BlockHoundIntegration.compareTo doesn't allow integrations loaded via SPI to control ordering based on initial position in stream. HOT 3
- build a skip or disable feature for individual tests HOT 2
- BlockHound does not support java 18
- Blockhound turn off and on for junit platform HOT 2
- Thread.sleep not detected HOT 2
- ClassCircularityError when using the agent with Tomcat HOT 7
- BlockHoundTestExecutionListener could not be instantiated (JDK 17) HOT 3
- unnamed module @45312be2 HOT 8
- Candidates to be included as default allowances
- Blockhound failing with new version of micrometer HOT 24
- Error using java 17 & infinispan starter HOT 4
- [Byte Buddy] ERROR reactor.core.publisher.ContextPropagation [jdk.internal.loader.ClassLoaders$AppClassLoader@266474c2, unnamed module @6c9f5c0d, Thread[mythread-1,5,main], loaded=false] HOT 5
- Bootstrap loading
- Using JDK 18 or greater makes the JVM log an issue while loading `Unsafe.park` HOT 1
- BlockHound does not flag Thread.sleep(long, int) since JDK 21 HOT 2
- Detect Synchronized Methods HOT 1
- Java 22 Support HOT 11
- Blockhound + Opentelemetry agent fail on install HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blockhound.