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

Downloading missing blob does not automatically re-fetch from remote

Details

    Description

      SYMPTOM:

      After migrating to NewDB (PostgreSQL or H2), trying to download some asset via proxy repository returns 500, and nexus.log shows "Attempt to access soft-deleted blob" and "MissingBlobException" like below:

      2022-08-30 12:53:58,952+1000 WARN  [qtp1548620246-103] *UNKNOWN org.sonatype.nexus.blobstore.file.FileBlobStore - Attempt to access soft-deleted blob f49953c3-a76d-467d-997e-c8ed71f3352c attributes: /Users/hosako/Documents/tests/nxrm-3.38.0_3.41.0/nexus-3.41.0/sonatype-work/nexus3/blobs/default/content/vol-20/chap-36/f49953c3-a76d-467d-997e-c8ed71f3352c.properties {deleted=true, @BlobStore.created-by=admin, creationTime=1661477012627, @BlobStore.created-by-ip=127.0.0.1, @BlobStore.content-type=application/java-archive, sha1=2973d150c0dc1fefe998f834810d68f278ea58ec, @BlobStore.blob-name=/junit/junit/4.12/junit-4.12.jar, @Bucket.repo-name=maven-central, size=314932}
      2022-08-30 12:53:59,143+1000 WARN  [qtp1548620246-103] *UNKNOWN org.sonatype.nexus.repository.httpbridge.internal.ViewServlet - Failure servicing: GET /repository/maven-central/junit/junit/4.12/junit-4.12.jar
      org.sonatype.nexus.repository.MissingBlobException: Blob default@0fe44557-c71d2261-aa97e2d5-6cb8b933-746aafb8:f49953c3-a76d-467d-997e-c8ed71f3352c exists in metadata, but is missing from the blobstore
      	at org.sonatype.nexus.repository.content.fluent.internal.FluentAssetImpl.download(FluentAssetImpl.java:173)
      	at java.util.Optional.map(Optional.java:215)
      	at org.sonatype.nexus.content.maven.internal.recipe.MavenContentFacetImpl.get(MavenContentFacetImpl.java:209)
      	at org.sonatype.nexus.content.maven.internal.recipe.MavenProxyFacet.getCachedContent(MavenProxyFacet.java:88)
      	at org.sonatype.nexus.repository.proxy.ProxyFacetSupport.maybeGetCachedContent(ProxyFacetSupport.java:413)
      	at org.sonatype.nexus.repository.proxy.ProxyFacetSupport.get(ProxyFacetSupport.java:271)
      ...
      

      REPRODUCE STEPS:

      1. Install Nexus 3.41.0 with H2 or PostgreSQL.
      2. Download some asset (eg: /repository/maven-central/junit/junit/4.12/junit-4.12.jar)
      3. Find above blob's properties file from the blob store by using the BlobID in the Blob Reference
      4. Append "deleted=true" in this .properties file
      5. Download junit-4.12.jar again => immediate 500
      6. Remove or rename this .properties file
      7. Download junit-4.12.jar again => immediate 500

      EXPECTED BEHAVIOUR:

      As per NEXUS-12388, Nexus should automatically try re-fetching the missing asset, rather than returning 500.

      CAUSE:

       the code is expecting "RetryDeniedException" but FluentAsset::download seems to throw "MissingBlobException" when the blob is null.

       

      Technical notes

      • We should avoid duplicates on the database when re-fetching an asset, that being said, we should catch the MissingBlobException (when an asset blob is soft deleted), delete the records of the 'soft-deleted' blod & re-throw a new exception for later usage on ProxyFacetSupport#maybeGetCachedContent  (we should return null from this method to perform a re-fetch of the asset)

       Acceptance criteria for the ticket

      • When a 'soft-deleted' blob is found, nexus should catch the exception & erase the related records (asset/asset blob) to this blob
      • Download of a 'soft-deleted' asset using a file blob store should re-fetch the asset

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              hosako Hajime Osako
              Michael Oliverio Michael Oliverio
              NXRM - Neo
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:

                tigCommentSecurity.panel-title