Fix flaky P2 test failures caused by parallel fork lock contention#2943
Conversation
|
Is there any chance we can fix the underlying issue? We're getting similar issues in CI across different builds, e.g. when they run simultaneously. |
|
Fixing the underlying issue means fixing something in Solstice. We have so many problems integrating with the eclipse ecosystem. My advice to end users is to migrate to a different platform, but I'm happy to keep merging PRs from interested parties. |
|
What exactly do you mean by "different platform"? For Groovy code formatting, the options are pretty limited unfortunately. |
|
lol, fair point. I guess I would take one of the following options:
My personal vote for my work on Spotless is that I'm just gonna accept the P2 weirdness. But if that was unacceptable, I would do 2 or 3. If you want to fix Solstice and the whole p2 deployment / GrEclipse tooling ecosystem, I think doing 1, 2, or 3 would almost certainly be a more efficient use of time. But I'll merge any PR that meets a reasonable quality bar! |
|
I guess I'll also go with option 1 then. I just wanted to make sure that I'm not missing an obvious alternative. I just noticed that locking issues in the Groovy formatter habe become more common in the last couple months or so. But maybe we're just running more builds. 🤷🏼♂️ |
This PR aims to fix Fix flaky P2 test failures.
Context
lib-extra:testruns withmaxParallelForks = Runtime.runtime.availableProcessors().intdiv(2).Each Gradle test fork is a separate JVM. When multiple forks simultaneously call
model.query(), they race for a process-level file lock causing one of the 2 forks to get an IllegalStateException (P2 operation already in progress).TestP2Provisioneralready has sync mechanism, but that only works within one JVM and not across multiple forks.Fix
Override
maxParallelForks = 1inlib-extra/build.gradle. One fork is enough because theTestP2Provisionersynch handles thread safety within one JVM, and its disk cache ensures P2 deps are provisioned once and reused across all test classes.I don't expect meaningful slowdown since with 2 forks the parallel gain was already lost to lock failures and
testRetryreschedules. Also, I expect this to make the pipeline more stable.