Uploaded image for project: 'Jackrabbit Oak'
  1. Jackrabbit Oak
  2. OAK-2418

int overflow with orderby causing huge slowdown

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.0.9
    • 1.0.10, 1.1.6
    • core
    • None

    Description

      Consider the following query:

      //element(*,slingevent:Job) order by @slingevent:created ascending
      

      this query - when running with a large number of slingevent:Job around - will take a very long time due to the fact, that FilterIterators.SortIterator.init() in the following loop:

      if (list.size() > max * 2) {
        // remove tail entries right now, to save memory
        Collections.sort(list, orderBy);
        keepFirst(list, max);
      }
      

      does a multiplication with 'max', which is by default set to Integer.MAX_VALUE (see FilterIterators.newCombinedFilter). This results in max *2 to overflow (result is -2) - thus that init-loop will sort the list for every additional entry. Which is definitely not the intention.

      Attachments

        1. oak-2418.patch
          0.8 kB
          Stefan Egli

        Activity

          People

            thomasm Thomas Mueller
            stefanegli Stefan Egli
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: