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

Faulty handling of query timeouts in OrientAsyncHelper.QueueConsumingIterable

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.2.0, 3.2.1
    • Fix Version/s: 3.3.0
    • Component/s: Database
    • Labels:
      None
    • Story Points:
      2
    • Sprint:
      Sprint 89

      Description

      https://github.com/sonatype/nexus-internal/blob/c341bcc9311c122cc17d51df0abb30920b2fe33f/components/nexus-repository/src/main/java/org/sonatype/nexus/repository/storage/OrientAsyncHelper.java#L184

      The queue.poll() invocation there yields no exception but null when the timeout elapses. This causes the following issues:

      1. hasNext() returning true when in reality no element is available
      2. next() returning a non-deterministic number of null elements tripping up processing of the query results, e.g.
        2017-01-10 15:09:20,084+0100 ERROR [qtp172586730-295] admin org.sonatype.nexus.extdirect.internal.ExtDirectServlet - Failed to invoke action method: coreui_Component.read, java-method: org.sonatype.nexus.coreui.ComponentComponent.read
        java.lang.IllegalArgumentException: expected one element but was: <null, null, null, null, null, ...>
                at com.google.common.collect.Iterators.getOnlyElement(Iterators.java:322) [com.google.guava:20.0.0]
                at com.google.common.collect.Iterables.getOnlyElement(Iterables.java:294) [com.google.guava:20.0.0]
                at org.sonatype.nexus.repository.browse.internal.BrowseServiceImpl.getCount(BrowseServiceImpl.java:192) [na:na]
                at org.sonatype.nexus.repository.browse.internal.BrowseServiceImpl.browseComponents(BrowseServiceImpl.java:95) [na:na]
                at org.sonatype.nexus.repository.browse.BrowseService$browseComponents.call(Unknown Source) [na:na]
                at org.sonatype.nexus.coreui.ComponentComponent.read(ComponentComponent.groovy:126) [na:na]
        
      3. next() failing with NoSuchElementException although the caller previously checked hasNext() == true (next() calls hasNext() again and can observe a different value than the caller, like the end-of-query sentinel), e.g.
        Suppressed: java.util.NoSuchElementException: Iterator depleted
          at org.sonatype.nexus.repository.storage.OrientAsyncHelper$QueueConsumingIterable.next(OrientAsyncHelper.java:202) [na:na]
          at org.sonatype.nexus.repository.storage.OrientAsyncHelper$QueueConsumingIterable.next(OrientAsyncHelper.java:1) [na:na]
          at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:47) [com.google.guava:20.0.0]
          at org.sonatype.nexus.repository.maven.internal.PurgeUnusedSnapshotsFacetImpl.deleteUnusedSnapshotComponents(PurgeUnusedSnapshotsFacetImpl.java:165) [na:na]
        

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bradbeck Brad Beck
              Reporter:
              bentmann Benjamin Bentmann
              Last Updated By:
              Peter Lynch
              Votes:
              5 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Date of First Response:

                  tigCommentSecurity.panel-title