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(LockSupport.java:175)
	at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836)
	at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:997)
	at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1304)
	at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:231)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:70)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:45)
	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:83)
	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:35)
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:117)
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:62)
	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:62)
	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:67)

I found this issue raised few times before but looks like was never resolved.
https://issues.gradle.org/browse/GRADLE-2169
https://issues.gradle.org/browse/GRADLE-2170
http://gradle.1045684.n5.nabble.com/Infinite-wait-running-tests-td5561210.html

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.