Thread Thread[vert.x-eventloop-thread-14,5,main] has been blocked for 5457 ms, time limit is 2000
vertx.executeBlocking(() -> {
// worker stuff here. can block
Thread.sleep() // not blocking
vertx.runOnContext(() -> {
Thread.sleep() // blocking
})
})
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/e7320f26-a2f9-4b02-8032-e0c183bb4160%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/26071808-e2b0-496f-86d4-9d9f519781e4%40googlegroups.com.
Context vertxContext = vertx.getOrCreateContext();
collection.find().forEach(o -> {
vertxContext.runOnContext(event1 -> {
try {
// doing something that blocks a while here
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
});
i get this when i debug the code i wonder if we could increase the time limit for the process
On Thu, Aug 2, 2018 at 8:46 AM, Steve Hummingbird <Steve.Hu...@yandex.com> wrote:
I just came across a pretty strange situation, which I haven't been able to fully figure out yet (pretty scarce on time at the moment).Basically the situation is as following:- I have a worker verticle- the worker verticle makes an async call to the mongo driver- the callback of the mongo driver calls vertx.runOnContext and inside that, we just call Thread.sleep() to blockThis leads to the following warning:Thread Thread[vert.x-eventloop-thread-14,5,main] has been blocked for 5457 ms, time limit is 2000
Note, this seems to be the main event loop(!!) and not the woker complaining about a long running task.To make this go away, I found two things that work:- Replace the call to the mongo driver with my own code which just spins up a new thread and sleeps before calling the callback. (so probably the mongo driver is doing something different than just ending up on another thread on the callback). This is actually pretty useless in practice.- Remove vertx.runOnContext from the mongodb callbackIn the end the question is: How is it possible to start on a worker verticle and end up blocking the main event loop? And why do I only see this when I use vertx.runOnContext (in combination with the mongo driver)?I can try to put up a simple reproducer in case this is helpful, but I wanted to get in touch first, since maybe there is a misunderstanding about the general concept here.
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/999c6757-4e3b-4323-b617-2749f41d0a58%40googlegroups.com.
So technically you're NOT blocking the "main" event loop either.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/86abdc0e-e652-448e-9e4a-43d03dd36fa8%40googlegroups.com.
On 3 Aug 2018, at 16:43, Steve Hummingbird <Steve.Hu...@yandex.com> wrote:Well, yes. In the end it is not very complex: whenever in doubt, store the context and afterwards put yourself on the context again. And then never ever use the vertx.runOnContext method unless you do find a good reason to.The thing about third party stuff is that there is a lot of code out there which makes use of threads where you probably would not expect it. May CompletableFuture serve as an example.I think one thing would be totally awesome: A section in the docs that mentions how to deal with code which uses threads. Like what can happen if you run something on a different context or thread. What is not safe to do when on a different context/thread (e.g. what will happen if you do it anyways). I think most people only stumble upon that stuff when they are already hitting an issue and most likely have already written a lot of code they now need to refactor. And then they start reading various postings or blogs and often only get an incomplete picture.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/436df36e-3e48-4b84-805b-7a87263035ac%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/e74f716c-b55a-4f39-acbe-9d186c336e4e%40googlegroups.com.