Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

NEXUS-5654 fixed endless autorouting initialization restart

Hosted repositories autorouting initialization involves deep walk
of entire repository local storage and is likely to take significant
time for large nexus installations like OSSRH. In attempt to prevent
lost-update race between artifact deploy/delete and hosted repositry
autorouting initiazation, deploy/delete unconditionally restarted
initization which could lead to apparently endless initialization if
time between deployment is less than initiazation time (again, not
impossible for larger nexus installations).

The fix is to never restart initialization logic during artifact
deploy. This is not bulletproof and can result in missing prefix
entries if deployment of new top-level groupId happens after certain
point during repository autorouting initiazation, but I believe
this is going to be very unlikely (assumption is that new top
groupIds are very rare for populated hosted repositories and
initiazation is very quick for new/empty hosted repositories). If
this does happen, the workaround is to delete prefix file and
wait for 1hr for another initilization attempt to take place.

In order to completely eliminate possibility of race between
artifact deploy and autorouting initiazation we'd need to extend
RepositoryItemUidLock API to allow lock-with-timeout, something
I decided was too tricky and risky this late in 2.4 cycle.

Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
  • Loading branch information...
commit 40645544f6c7cd10612a8c2dea3e8bed098b7bc4 1 parent 85afc33
@ifedorenko ifedorenko authored
View
14 nexus-core/src/main/java/org/sonatype/nexus/proxy/maven/routing/internal/ManagerImpl.java
@@ -872,8 +872,11 @@ public boolean offerEntry( final MavenHostedRepository mavenHostedRepository, fi
{
if ( constrainedExecutor.hasRunningWithKey( mavenHostedRepository.getId() ) )
{
- forceUpdatePrefixFile( mavenHostedRepository );
- return true;
+ // as of 2.4 this is only possible during initial autorouting configuration of hosted repositories
+ // any changes to prefix list performed here will be incomplete, i.e. list single path prefix
+ // and it will be overwritten when initial autorouting configuration completes
+ // although not 100% bulletproof, this logic reduces the risk of this happening
+ return false;
}
final FilePrefixSource prefixSource = getPrefixSourceFor( mavenHostedRepository );
final RepositoryItemUidLock lock = prefixSource.getRepositoryItemUid().getLock();
@@ -921,8 +924,11 @@ public boolean revokeEntry( final MavenHostedRepository mavenHostedRepository, f
{
if ( constrainedExecutor.hasRunningWithKey( mavenHostedRepository.getId() ) )
{
- forceUpdatePrefixFile( mavenHostedRepository );
- return true;
+ // as of 2.4 this is only possible during initial autorouting configuration of hosted repositories
+ // any changes to prefix list performed here will be incomplete, i.e. list single path prefix
+ // and it will be overwritten when initial autorouting configuration completes
+ // although not 100% bulletproof, this logic reduces the risk of this happening
+ return false;
}
final FilePrefixSource prefixSource = getPrefixSourceFor( mavenHostedRepository );
final RepositoryItemUidLock lock = prefixSource.getRepositoryItemUid().getLock();

1 comment on commit 4064554

@peterlynch
Owner

agree with sentiments of @ifedorenko 's comments - can we write a test which proves init will not restart on deploy?

Please sign in to comment.
Something went wrong with that request. Please try again.