2

The case is that an application hangs infinitely from time to time.

Seems that the bug sits in the following snippet:

ForkJoinPool pool = new ForkJoinPool(1); // parallelism = 1 List<String> entries = ...; pool.submit(() -> { entries.stream().parallel().forEach(entry -> { // An I/O op. ... }); }).get(); 

Thread pool-4-thread-1 that executes the code freezes on get():

"pool-4-thread-1" #35 prio=5 os_prio=0 tid=0x00002b42e4013800 nid=0xb7d1 in Object.wait() [0x00002b427b72f000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) at java.util.concurrent.ForkJoinTask.externalInterruptibleAwaitDone(ForkJoinTask.java:367) - locked <0x00000000e08b68b8> (a java.util.concurrent.ForkJoinTask$AdaptedRunnableAction) at java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:1001) ...other app methods 

One can assume that the task passed to submit() executes too long.

But surprisingly there is no ForkJoinPool-N-worker-N occurrences in the thread dump, so looks like the pool doesn't perform any computations!

How is that possible? If no tasks are executed by the pool, why pool-4-thread-1 thread waits inside get()?

P.S. I know that it's not recommended to execute I/O-related tasks in ForkJoinPool, but still interested in the root of the problem.

Update. When parallelism is set to value greater than 1, no problems are detected.

5
  • 1
    Check this question: stackoverflow.com/questions/5493399/… Commented Apr 28, 2018 at 14:27
  • What other thread(s) does the thread dump show? .get() is obviously still waiting for some computation. Commented Apr 28, 2018 at 14:55
  • @manouti full stacktrace can be found here: paste.ix/QS02o Commented Apr 28, 2018 at 15:10
  • @Ivan thanks. Seems that the issue in the given question has been already solved for my JVM version. Commented Apr 28, 2018 at 15:11
  • @Aliaxander maybe not all cases were fixed and you need to raise a bug for OpenJDK. Commented Apr 28, 2018 at 15:16

1 Answer 1

1

Set parallelism = N where N > 1 solved the problem.

Strange thing but seems that there is some bug in ForkJoinPool similar to what is stated here.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.