I tried running parallel tasks using Gradle single project in a kubernetes pod but I’m facing issue stating “Timeout waiting to lock checksums cache. It is currently in use by another Gradle instance.”
There are some Workaround suggestions to use GRADLE_USER_HOME but I’m not sure if that can be used in Kubernetes volumes as similar in Jenkins Workspace (env).
Can someone help me here with any sort of information for achieving the same.
Gradle Version used - 7.4
It is unclear to me what you are asking for actually.
If you want to run tasks in parallel within one project of a Gradle build, those tasks either have to use the worker API, or you have to have the configuration cache enabled, and the tasks not depending on each other.
And in either case running those tasks in parallel should work fine without any locks being a problem.
If you run two Gradle builds of the same project in parallel as separate processes, they can maybe disturb each other as two daemons will be used to run them and the second one could starve waiting for some lock held by the first one if it needs too long to free the lock. This could of course be worked-around with different Gradle User Home directories, but then it would also not be able to reuse dependencies, but download everything twice and so on.
Thanks for the reply!.
Yes, I guess this will work for me (I need to check the feasibility to run two Gradle builds of the same project in parallel by creating different Gradle User Home directories).
Do you also have any information for doing the same with Kubernetes Persistent Volumes ?
I might need to create sub-dirs inside persistent volume claimed and download everything (Gradle setup, tests) in each of sub-dirs and run Gradle independently ?
I also came across this: after setting a separate GRADLE_HOME it still failed because the .gradle directory of the project is shared (there are different locks involved). So you would need a separate gradle home plus a separate project checkout, which really complicates things.
It looks like gradle isn’t well suited for containers with shared storage.
@jberkel Yes that true. Ran into the same recently. If only we could pass in a custom path for .gradle directory of the project, we could copy the original content and run two gradle task separately