Gradle build hangs forever on CountDownLatch

(John Soman) #1

My gradle build hangs forever. It happens when running tests. When I take a threadump i see that main thread is stuck on CountdownLatch.

"main" #1 prio=5 os_prio=0 tid=0x0000000000e9a000 nid=0x264c waiting on condition [0x000000000122f000]
   java.lang.Thread.State: WAITING (parking)
	at sun.misc.Unsafe.park(Native Method)
	- parking to wait for  <0x0000000700a39cf8> (a java.util.concurrent.CountDownLatch$Sync)
	at java.util.concurrent.locks.LockSupport.park(
	at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(
	at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(
	at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(
	at java.util.concurrent.CountDownLatch.await(
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(
	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(
	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(

I found this issue raised few times before but looks like was never resolved.

Does anyone know of any solution/workaround to this?
I’m on gradle 4.1 running on Windows. I observed the same problem with 2.4

(John Soman) #2

Anyone? This seems to be more frequent with Gradle 4.1 than it was with 2.4 ! On 2.4 happened occasionally, now after upgrade it breaks our continuous integration build on Team City at least daily… I’m wondering if there is anything we may be doing wrong with Gradle setup that is causing such behaviour, but it is a fairly standard multiproject setup I think.

(Benjamin Muschko) #3

The lock is originating from org.gradle.api.internal.tasks.testing.worker.TestWorker. My gut feeling tells me that one your tests runs into an endless loop or locks on some resource and therefore never finishes. Maybe you can add some test logging to see which test is currently running.