Bug 394998 - InternalErrorException when running builds in parallel on the same Maven repository
Summary: InternalErrorException when running builds in parallel on the same Maven repo...
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Tycho (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal with 5 votes (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-23 15:48 EST by Steffen Pingel CLA
Modified: 2021-04-28 16:54 EDT (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steffen Pingel CLA 2012-11-23 15:48:51 EST
I have a matrix job in Hudson that run a dozen Tycho 0.16 builds in parallel using Maven 3.0.4. All builds use the same target platform configuration and the same local Maven repository. When I triggered the matrix job almost all builds failed with the error below.

I suspect the error was caused by another job performing the same rename operation but it's also strange that it's trying to rename the file to the same name:

/work/hudson/node/home/.m2/repository/.cache/tycho/p2-repository-metadata/downloading/content-690616077.xml could not be renamed to 
/work/hudson/node/home/.m2/repository/.cache/tycho/p2-repository-metadata/downloading/content-690616077.xml

[INFO] Computing target platform for MavenProject: ...
[INFO] Adding repository https://...
[INFO] Adding repository https://...
[INFO] o.h.m.e.h.MavenExecutionResultHandler - Build failed with exception(s)
[INFO] o.h.m.e.h.MavenExecutionResultHandler - [1] org.apache.maven.InternalErrorException: Internal error: java.lang.RuntimeException: Failed to resolve target definition /work/hudson/node/home/.m2/repository/.../my-target.target
[DEBUG] Closing connection to remote
[ERROR] Internal error: java.lang.RuntimeException: Failed to resolve target definition /work/hudson/node/home/.m2/repository/.../my-target.target: Failed to load metadata repository from location https://.../: An error occurred while downloading https://.../content.xml. The cache file /work/hudson/node/home/.m2/repository/.cache/tycho/p2-repository-metadata/downloading/content-690616077.xml could not be renamed to /work/hudson/node/home/.m2/repository/.cache/tycho/p2-repository-metadata/downloading/content-690616077.xml. -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: java.lang.RuntimeException: Failed to resolve target definition /work/hudson/node/home/.m2/repository/.../my-target.target
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:168)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: java.lang.RuntimeException: Failed to resolve target definition /work/hudson/node/home/.m2/repository/.../my-target.target
	at org.eclipse.tycho.p2.resolver.P2TargetPlatformResolver.addTargetFileContentToTargetPlatform(P2TargetPlatformResolver.java:338)
	at org.eclipse.tycho.p2.resolver.P2TargetPlatformResolver.computeTargetPlatform(P2TargetPlatformResolver.java:207)
	at org.eclipse.tycho.core.resolver.DefaultTychoDependencyResolver.resolveProject(DefaultTychoDependencyResolver.java:94)
	at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.afterProjectsRead(TychoMavenLifecycleParticipant.java:82)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:274)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
	... 11 more
Caused by: org.eclipse.tycho.p2.target.facade.TargetDefinitionResolutionException: Failed to load metadata repository from location https://.../
	at org.eclipse.tycho.p2.target.TargetDefinitionResolver.loadRepository(TargetDefinitionResolver.java:190)
	at org.eclipse.tycho.p2.target.TargetDefinitionResolver.resolveContent(TargetDefinitionResolver.java:109)
	at org.eclipse.tycho.p2.target.TargetDefinitionResolverService.resolveFromArguments(TargetDefinitionResolverService.java:64)
	at org.eclipse.tycho.p2.target.TargetDefinitionResolverService.getTargetDefinitionContent(TargetDefinitionResolverService.java:54)
	at org.eclipse.tycho.p2.target.TargetPlatformBuilderImpl.addTargetDefinition(TargetPlatformBuilderImpl.java:289)
	at org.eclipse.tycho.p2.resolver.P2TargetPlatformResolver.addTargetFileContentToTargetPlatform(P2TargetPlatformResolver.java:331)
	... 16 more
Caused by: org.eclipse.equinox.p2.core.ProvisionException: An error occurred while downloading https://.../content.xml. The cache file /work/hudson/node/home/.m2/repository/.cache/tycho/p2-repository-metadata/downloading/content-690616077.xml could not be renamed to /work/hudson/node/home/.m2/repository/.cache/tycho/p2-repository-metadata/downloading/content-690616077.xml.
	at org.eclipse.equinox.internal.p2.repository.CacheManager.updateCache(CacheManager.java:371)
	at org.eclipse.equinox.internal.p2.repository.CacheManager.createCache(CacheManager.java:208)
	at org.eclipse.tycho.p2.remote.TychoP2RepositoryCacheManager.createCache(TychoP2RepositoryCacheManager.java:62)
	at org.eclipse.equinox.internal.p2.metadata.repository.SimpleMetadataRepositoryFactory.getLocalFile(SimpleMetadataRepositoryFactory.java:66)
	at org.eclipse.equinox.internal.p2.metadata.repository.SimpleMetadataRepositoryFactory.load(SimpleMetadataRepositoryFactory.java:88)
	at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.factoryLoad(MetadataRepositoryManager.java:57)
	at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadRepository(AbstractRepositoryManager.java:758)
	at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadRepository(AbstractRepositoryManager.java:651)
	at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.loadRepository(MetadataRepositoryManager.java:96)
	at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.loadRepository(MetadataRepositoryManager.java:92)
	at org.eclipse.tycho.p2.remote.RemoteMetadataRepositoryManager.loadRepository(RemoteMetadataRepositoryManager.java:82)
	at org.eclipse.tycho.p2.target.TargetDefinitionResolver.loadRepository(TargetDefinitionResolver.java:188)
	... 21 more
Comment 1 Jan Sievers CLA 2012-11-26 03:26:14 EST
making the p2 access to local repo content/cache files multi-process safe was not covered by the work done in bug 347963.

Not sure if this can be done in tycho or has to be fixed in p2.
I think the main scenario in p2 (IDE install/update) does not have multi-process access to metadata cache files.
Comment 2 Jan Sievers CLA 2012-11-26 03:54:31 EST
> I suspect the error was caused by another job performing the same rename
> operation but it's also strange that it's trying to rename the file to the
> same name:

the cache file name is calculated from the repo URL AFAIK.
Comment 3 Steffen Pingel CLA 2012-11-26 05:43:10 EST
Unfortunately it's still not possible to use shared local Maven caches due to that bug and others. We are also seeing JVM crashes related to opened zip files being changed by other processes.
Comment 4 Jan Sievers CLA 2012-11-27 03:27:29 EST
(In reply to comment #3)
> Unfortunately it's still not possible to use shared local Maven caches due
> to that bug and others. We are also seeing JVM crashes related to opened zip
> files being changed by other processes.

note that maven core still does not support multi-process access to local maven repo
http://wiki.eclipse.org/Tycho/Release_Notes/0.14

regardless of what we are fixing in tycho, you may still see issues with maven core.

That said, this bug is valid and should be fixed.
Comment 5 Tobias Oberlies CLA 2012-12-06 10:34:23 EST
(In reply to comment #1)
> Not sure if this can be done in tycho or has to be fixed in p2.
> I think the main scenario in p2 (IDE install/update) does not have multi-process
> access to metadata cache files.
We are using our own p2 artifact repository implementation, so this should be possible.

IMHO, a start would be to provide unit tests that reproduces the problem. That test would need to write into multiple LocalArtifactRepository instances that persist in the same file system location. Good contributions are welcome. [1]

[1] http://wiki.eclipse.org/Tycho/Contributor_Guide
Comment 6 Tobias Oberlies CLA 2013-01-03 05:45:41 EST
(In reply to comment #3)
> Unfortunately it's still not possible to use shared local Maven caches due to
> that bug and others. We are also seeing JVM crashes related to opened zip files
> being changed by other processes.
Yes, I can see how this can happen: A second build process may download to an artifact file which has just been downloaded (and is being used) by the first build process. I've opened bug 397355 to address this problem.

The problem reported here however is different: As stated before (comment #1), this bug is about conflicting access to the local copies of remote repository index files. This index caching is done by one of the standard p2 repository implementations and not by our own implementation, so we really may need to fix this in the p2 code. (My last comment was wrong about this.)
Comment 7 Kai Zimmermann CLA 2013-03-01 07:33:18 EST
+1
Comment 8 Tobias Oberlies CLA 2014-01-31 08:30:59 EST
*** Bug 426697 has been marked as a duplicate of this bug. ***
Comment 9 Christian Schneider CLA 2015-01-28 04:39:43 EST
Note, the file name is actually not the same, but the error message is wrong. It is created from the following template: "An error occurred while downloading {0}. The cache file {1} could not be renamed to {1}."
Comment 10 Vasili Gulevich CLA 2015-11-03 06:22:21 EST
Reproduced on Tycho 0.23.1. No parralel builds were active.
Comment 11 Mickael Istria CLA 2021-04-08 18:07:10 EDT
Eclipse Tycho is moving away from this bugs.eclipse.org issue tracker to https://github.com/eclipse/tycho/issues/ instead. If this issue is relevant to you, your action is required.
0. Verify this issue is still happening with latest Tycho 2.4.0-SNAPSHOT
  if issue has disappeared, please change status of this issue to "CLOSED WORKFORME" with some details about your testing environment and how you did verify the issue; and you're done
  if issue is still present when latest release:
* Create a new issue at https://github.com/eclipse/tycho/issues/
  ** Use as title in GitHub the title of this Bugzilla ticket (may include the bug number or not, at your own convenience)
  ** In the GitHub description, start with a link to this bugzilla ticket
  ** Optionally add new content to the description if it can helps towards resolution
  ** Submit GitHub issue
* Update bugzilla ticket
  ** Add to "See also" property (up right column) the link to the newly created GitHub issue
  ** Add a comment "Migrated to <link-to-newly-created-GitHub-issue>"
  ** Set status as CLOSED MOVED
  ** Submit

All issues that remain open will be automatically closed next week or so. Then the Bugzilla component for Tycho will be archived and made read-only.