Skip to content

Fix flaky P2 test failures caused by parallel fork lock contention#2943

Open
mirkoalicastro wants to merge 1 commit into
diffplug:mainfrom
mirkoalicastro:fix/unstable-pipeline
Open

Fix flaky P2 test failures caused by parallel fork lock contention#2943
mirkoalicastro wants to merge 1 commit into
diffplug:mainfrom
mirkoalicastro:fix/unstable-pipeline

Conversation

@mirkoalicastro
Copy link
Copy Markdown
Contributor

@mirkoalicastro mirkoalicastro commented May 21, 2026

This PR aims to fix Fix flaky P2 test failures.

Context

lib-extra:test runs with maxParallelForks = 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).

TestP2Provisioner already has sync mechanism, but that only works within one JVM and not across multiple forks.

Fix

Override maxParallelForks = 1 in lib-extra/build.gradle. One fork is enough because the TestP2Provisioner synch 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 testRetry reschedules. Also, I expect this to make the pipeline more stable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant