Uploaded image for project: 'Dev - Nexus Repo'
  1. Dev - Nexus Repo
  2. NEXUS-34715

NullPointerException on null base_version during staging move operation maven metadata rebuild after upgrading to 3.40

    Details

    • Story Points:
      5
    • Sprint:
      NXRM MadMax Sprint 47
    • Notability:
      3

      Description

      A customer was publishing components using Maven REST API, while adding staging tags, then issues staging move to another repo while using Nexus version 3.37.3 PostgreSQL. Everything was fine.

      Customer upgraded to 3.40.1 postgreSQL and performs the exact same actions.

      When the customer uploads new maven component versions, on the new version, the upload fails with a 500 response and this stack trace:

      2022-08-15 10:54:20,563+0000 WARN  [qtp1989624189-66879]  username org.sonatype.nexus.repository.maven.internal.content.NativeDatastoreMetadataRebuilder - Error processing metadata for path: com/example/example-platform/example-platform-parent/maven-metadata.xml
      org.sonatype.nexus.repository.maven.internal.hosted.metadata.MetadataException: Error processing metadata for path: com/example/example-platform/example-platform-parent/maven-metadata.xml
      	at org.sonatype.nexus.repository.maven.internal.content.NativeDatastoreMetadataRebuilder$Worker.rebuildArtifactMetadata(NativeDatastoreMetadataRebuilder.java:381)
      	at org.sonatype.nexus.repository.maven.internal.content.NativeDatastoreMetadataRebuilder$Worker.lambda$8(NativeDatastoreMetadataRebuilder.java:257)
      	at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:269)
      	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
      	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
      	at java.util.Collections$2.tryAdvance(Collections.java:4719)
      	at java.util.Collections$2.forEachRemaining(Collections.java:4727)
      	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
      	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
      	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
      	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
      	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:485)
      	at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:272)
      	at java.util.Collections$2.tryAdvance(Collections.java:4719)
      	at java.util.Collections$2.forEachRemaining(Collections.java:4727)
      	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
      	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
      	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
      	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
      	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:485)
      	at org.sonatype.nexus.repository.maven.internal.content.NativeDatastoreMetadataRebuilder$Worker.rebuildMetadata(NativeDatastoreMetadataRebuilder.java:268)
      	at org.sonatype.nexus.repository.maven.internal.content.NativeDatastoreMetadataRebuilder.rebuild(NativeDatastoreMetadataRebuilder.java:118)
      	at org.sonatype.nexus.repository.maven.internal.content.NativeDatastoreMetadataRebuilder.rebuildInTransaction(NativeDatastoreMetadataRebuilder.java:157)
      	at org.sonatype.nexus.content.maven.internal.recipe.MavenMetadataRebuildFacetImpl.rebuildMetadata(MavenMetadataRebuildFacetImpl.java:124)
      	at org.sonatype.nexus.content.maven.internal.recipe.MavenMetadataRebuildFacetImpl.rebuildMetadata(MavenMetadataRebuildFacetImpl.java:109)
      	at org.sonatype.nexus.repository.maven.internal.datastore.MavenContentDirector.lambda$1(MavenContentDirector.java:80)
      	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
      	at java.util.stream.DistinctOps$1$2.accept(DistinctOps.java:175)
      	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
      	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384)
      	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
      	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
      	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
      	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
      	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:485)
      	at org.sonatype.nexus.repository.maven.internal.datastore.MavenContentDirector.afterMove(MavenContentDirector.java:80)
      	at com.sonatype.nexus.staging.internal.datastore.DatastoreStagingService.move(DatastoreStagingService.java:174)
      	at com.sonatype.nexus.staging.internal.datastore.DatastoreStagingService$$EnhancerByGuice$$2028378248.GUICE$TRAMPOLINE(<generated>)
      	at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:74)
      	at org.sonatype.nexus.common.stateguard.MethodInvocationAction.run(MethodInvocationAction.java:39)
      	at org.sonatype.nexus.common.stateguard.StateGuard$GuardImpl.run(StateGuard.java:272)
      	at org.sonatype.nexus.common.stateguard.GuardedInterceptor.invoke(GuardedInterceptor.java:54)
      	at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:75)
      	at com.google.inject.internal.InterceptorStackCallback.invoke(InterceptorStackCallback.java:55)
      	at com.sonatype.nexus.staging.internal.datastore.DatastoreStagingService$$EnhancerByGuice$$2028378248.move(<generated>)
      	at com.sonatype.nexus.staging.internal.StagingResource.move(StagingResource.java:89)
      	at com.sonatype.nexus.staging.internal.StagingResource$$EnhancerByGuice$$2025874991.GUICE$TRAMPOLINE(<generated>)
      	at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:74)
      	at org.apache.shiro.guice.aop.AopAllianceMethodInvocationAdapter.proceed(AopAllianceMethodInvocationAdapter.java:49)
      	at org.apache.shiro.authz.aop.AuthorizingAnnotationMethodInterceptor.invoke(AuthorizingAnnotationMethodInterceptor.java:68)
      	at org.apache.shiro.guice.aop.AopAllianceMethodInterceptorAdapter.invoke(AopAllianceMethodInterceptorAdapter.java:36)
      	at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:75)
      	at com.google.inject.internal.InterceptorStackCallback.invoke(InterceptorStackCallback.java:55)
      	at com.sonatype.nexus.staging.internal.StagingResource$$EnhancerByGuice$$2025874991.move(<generated>)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:138)
      	at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:546)
      	at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:435)
      	at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$0(ResourceMethodInvoker.java:396)
      	at org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:358)
      	at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:398)
      	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:365)
      	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:338)
      	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:440)
      	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:229)
      	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:135)
      	at org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:358)
      	at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:138)
      	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:215)
      	at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:245)
      ....
      Caused by: java.lang.NullPointerException: null
      	at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:880)
      	at org.sonatype.nexus.repository.maven.internal.hosted.metadata.MetadataBuilder.addBaseVersion(MetadataBuilder.java:178)
      	at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1580)
      	at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:647)
      	at org.sonatype.nexus.repository.maven.internal.content.NativeDatastoreMetadataRebuilder$Worker.rebuildArtifactMetadata(NativeDatastoreMetadataRebuilder.java:367)
      	... 165 common frames omitted
      

      Diagnosis

      In this case for some reason for the move failure, the base_version column of the maven2_component table is null.

      select count(*) as nullcount from maven2_component where base_version is null;
      nullcount
      -----------
      992
      

      Since a new maven metadata rebuilder was introduced in issue NEXUS-32429, we suspect this new maven rebuilder may have an issue.

      Emergency Workaround - not a long term solution

      One can revert to the old legacy maven metadata rebuilder, which may have performance issues in some scenarios, but it will at least rebuild metadata without this error:

      Set this in nexus.properties and restart NXRM:

      nexus.maven.datastore.legacy.rebuild=true
      

      Expected

      If it is expected that base_version never have null values, then determine the cause of this and implement a fix for existing data with this problem ( ie. Upgrade step and fix).

      If metadata rebuilder is not correctly anticipating that base_version is null by design, then fix it.
      Please review org.sonatype.nexus.content.maven.internal.recipe.MavenContentFacetImpl#copy to make sure the component creation and updateBaseVersion are in same DB transaction.

      Also the new rebuilder code needs to expose a log message that can log the actual component record that has an unexpected value.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              sshamrai Sergii Shamrai
              Reporter:
              plynch Peter Lynch
              Last Updated By:
              Sergii Shamrai Sergii Shamrai
              Team:
              NXRM - Mad Max
              Owner:
              Sergii Shamrai Sergii Shamrai
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Date of First Response:

                  tigCommentSecurity.panel-title