Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for concurrent operations - P2 operation already in progress #146

Open
blacelle opened this issue Jun 24, 2023 · 2 comments
Open
Labels
enhancement New feature or request solstice-p2

Comments

@blacelle
Copy link

blacelle commented Jun 24, 2023

This issue relates (in term of context) with diffplug/spotless#1687

Through Spotless, I end needing to run concurrent P2 invocations in the same environment. It fails with:

Caused by: com.diffplug.spotless.ThrowingEx$WrappedAsRuntimeException: java.io.IOException: Failed to load eclipse jdt formatter: java.lang.IllegalStateException: P2 operation already in progress, close other clients or delete stale lockfile at /tmp/cleanthat/user_home/.m2/repository/dev/equo/p2-data/repository/dev/equo/p2-data/metadata/.lock
--
at com.diffplug.spotless.ThrowingEx.asRuntime(ThrowingEx.java:92)
at com.diffplug.spotless.LazyForwardingEquality.state(LazyForwardingEquality.java:58)
at com.diffplug.spotless.FormatterStep$Strict.format(FormatterStep.java:88)
at com.diffplug.spotless.Formatter.compute(Formatter.java:246)
at com.diffplug.spotless.PaddedCell.calculateDirtyState(PaddedCell.java:203)
at eu.solven.cleanthat.spotless.SpotlessSession.doStuff(SpotlessSession.java:109)
at eu.solven.cleanthat.language.spotless.SpotlessLintFixer.lambda$doFormat$0(SpotlessLintFixer.java:55)
... 18 common frames omitted
Caused by: java.io.IOException: Failed to load eclipse jdt formatter: java.lang.IllegalStateException: P2 operation already in progress, close other clients or delete stale lockfile at /tmp/cleanthat/user_home/.m2/repository/dev/equo/p2-data/repository/dev/equo/p2-data/metadata/.lock
at com.diffplug.spotless.extra.EquoBasedStepBuilder.get(EquoBasedStepBuilder.java:109)
at com.diffplug.spotless.FormatterStepImpl.calculateState(FormatterStepImpl.java:58)
at com.diffplug.spotless.LazyForwardingEquality.state(LazyForwardingEquality.java:56)
... 23 common frames omitted
Caused by: java.lang.IllegalStateException: P2 operation already in progress, close other clients or delete stale lockfile at /tmp/cleanthat/user_home/.m2/repository/dev/equo/p2-data/repository/dev/equo/p2-data/metadata/.lock
at dev.equo.solstice.p2.LockFile.lambda$new$0(LockFile.java:37)
at dev.equo.solstice.p2.FileMisc.retry(FileMisc.java:101)
at dev.equo.solstice.p2.LockFile.<init>(LockFile.java:31)
at dev.equo.solstice.p2.P2Client.<init>(P2Client.java:65)
at dev.equo.solstice.p2.P2Model.queryRaw(P2Model.java:94)
at dev.equo.solstice.p2.P2Model.query(P2Model.java:125)
at com.diffplug.spotless.extra.EquoBasedStepBuilder.get(EquoBasedStepBuilder.java:107)
... 25 common frames omitted

This is recurrent in my use-case as I run multiple Spotless|P2 processes on the same machine.

I have no equivalent issue with maven, which handles smoothly concurrent invocations on a common/shared ~/.m2/repository directory. Which makes me feel P2 could/should cover the same useCase.

I would be fine if concurrent operations were kept pending until the lock is freed, instead of hard-failing. This may be a relevant optional behavior.

@nedtwigg
Copy link
Collaborator

I agree it ought to handle concurrent invocations, or at the very least not fail while it waits in serial. In the short-term, the timeout goes from 5s to 50s if you set the system property lockFileGenerousTimeout to true.

private static final int WAIT_FOR_BUSY = 5_000;
private static final int WAIT_FOR_BUSY_CI = 50_000;
LockFile(File dir) throws IOException {
FileMisc.mkdirs(dir);
lockFile = new File(dir, ".lock");
int timeout =
System.getProperty("lockFileGenerousTimeout") != null ? WAIT_FOR_BUSY_CI : WAIT_FOR_BUSY;

@nedtwigg nedtwigg added enhancement New feature or request solstice-p2 labels Jun 24, 2023
@blacelle
Copy link
Author

blacelle commented Aug 1, 2023

The 50s generous timeout seems sufficient for my case. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request solstice-p2
Projects
None yet
Development

No branches or pull requests

2 participants