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

Race condition can cause component upload to fail.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Parked
    • Affects Version/s: 2.14.5
    • Fix Version/s: None
    • Component/s: Repository, Scheduled Tasks
    • Labels:
      None
    • Story Points:
      3

      Description

      If a large file is uploaded while a snapshot removal task is running it can fail with a file not found error. This is a rare race condition, but it can happen.

      This is because the directories needed in the target repository are made here:

      https://github.com/sonatype/nexus-public/blob/release-2.14.5-02/components/nexus-core/src/main/java/org/sonatype/nexus/proxy/storage/local/fs/DefaultFSPeer.java#L159

      Only after this is the file actually stored, and then after it is stored Nexus attempts to rename it to it's final destination:

      https://github.com/sonatype/nexus-public/blob/release-2.14.5-02/components/nexus-core/src/main/java/org/sonatype/nexus/proxy/storage/local/fs/DefaultFSPeer.java#L190

      But at that point a snapshot removal task may have deleted it's destination directory.

      This was actually observed in a user's log files. They had an upload that finished at "26/Sep/2017:07:39:42 -0700", and ran for 790 seconds.

      A snapshot removal task finished at 07:35:32:

      2017-09-26 07:35:32 INFO [pxpool-1-thread-8] *TASK org.sonatype.nexus.maven.tasks.SnapshotRemoverTask - Scheduled task (Clean snapshots) finished :: Removing snapshots from repository snapshots (started 2017-09-26T07:00:00-07:00, runtime 0:35:32.538)
      

      And then a few minutes later the upload failed because the destination directory didn't exist anymore.

      2017-09-26 07:39:41 WARN [qtp1960493218-140575] ctodev org.sonatype.nexus.proxy.storage.local.fs.DefaultFSPeer - Could not delete file: /nexus-data/snapshots/com/somewhere/someplace/someproject/someartifact/2017R11-8fd74a7132-SNAPSHOT/someartifact-2017R11-8fd74a7132-20170926.142632-1.zip
      java.nio.file.NoSuchFileException: /nexus-data/snapshots/.nexus/tmp/someartifact-2017R11-8fd74a7132-20170926.142632-1.zipnx-tmp383300099789364522.nx-upload -> /nexus-data/snapshots/com/somewhere/someplace/someproject/someartifact/2017R11-8fd74a7132-SNAPSHOT/someartifact-2017R11-8fd74a7132-20170926.142632-1.zip
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            rseddon Rich Seddon
            Last Updated By:
            Peter Lynch
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Date of First Response:

                tigCommentSecurity.panel-title