Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-16567

java.lang.StackOverflowError when combining KnnQParser and FunctionRangeQParser

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 9.1
    • 9.1.1
    • query
    • Solr Cloud with `solr:9.1` Docker image

    Description

      Hello there!

      I had a Solr 9.0 cluster running, using the new Dense Vector feature. Recently I have migrated to Solr 9.1. Most of the things are working fine, except for a special case I have here.

      Error Description

      The problem happens when I try making an Edismax query with a KNN sub-query and a Function Range filter. For example, I try making this query.

      • defType=edismax
      • df=name
      • q=the
      • similarity_vector={!knn f=vector topK=10}[1.1,2.2,3.3,4.4]
      • {!frange l=0.99}

        $similarity_vector

      In other words, I want all the documents matching the term "the" in the "name" field, and I filter to return only documents having a vector similarity of at least 0.99. This query was working fine on Solr 9.0, but on Solr 9.1, I get his error:

       

      java.lang.RuntimeException: java.lang.StackOverflowError    at org.apache.solr.servlet.HttpSolrCall.sendError(HttpSolrCall.java:840)    at org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:641)    at org.apache.solr.servlet.SolrDispatchFilter.dispatch(SolrDispatchFilter.java:250)    at org.apache.solr.servlet.SolrDispatchFilter.lambda/usr/bin/zsh(SolrDispatchFilter.java:218)    at org.apache.solr.servlet.ServletUtils.traceHttpRequestExecution2(ServletUtils.java:257)    at org.apache.solr.servlet.ServletUtils.rateLimitRequest(ServletUtils.java:227)    at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:213)    at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:195)    at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:201)    ... (manually supressed for brevity)    at java.base/java.lang.Thread.run(Unknown Source)Caused by: java.lang.StackOverflowError    at org.apache.solr.search.StrParser.getId(StrParser.java:172)    at org.apache.solr.search.StrParser.getId(StrParser.java:168)    at org.apache.solr.search.QueryParsing.parseLocalParams(QueryParsing.java:100)    at org.apache.solr.search.QueryParsing.parseLocalParams(QueryParsing.java:65)    at org.apache.solr.search.QParser.getParser(QParser.java:364)    at org.apache.solr.search.QParser.getParser(QParser.java:334)    at org.apache.solr.search.QParser.getParser(QParser.java:321)    at org.apache.solr.search.QueryUtils.parseFilterQueries(QueryUtils.java:244)    at org.apache.solr.search.neural.KnnQParser.getFilterQuery(KnnQParser.java:93)    at org.apache.solr.search.neural.KnnQParser.parse(KnnQParser.java:83)    at org.apache.solr.search.QParser.getQuery(QParser.java:188)    at org.apache.solr.search.FunctionQParser.parseValueSource(FunctionQParser.java:384)    at org.apache.solr.search.FunctionQParser.parse(FunctionQParser.java:94)    at org.apache.solr.search.QParser.getQuery(QParser.java:188)    at org.apache.solr.search.FunctionRangeQParserPlugin.parse(FunctionRangeQParserPlugin.java:53)    at org.apache.solr.search.QParser.getQuery(QParser.java:188)    at org.apache.solr.search.QueryUtils.parseFilterQueries(QueryUtils.java:246)    at org.apache.solr.search.neural.KnnQParser.getFilterQuery(KnnQParser.java:93)    at org.apache.solr.search.neural.KnnQParser.parse(KnnQParser.java:83)    at org.apache.solr.search.QParser.getQuery(QParser.java:188)    at org.apache.solr.search.FunctionQParser.parseValueSource(FunctionQParser.java:384)    at org.apache.solr.search.FunctionQParser.parse(FunctionQParser.java:94)    at org.apache.solr.search.QParser.getQuery(QParser.java:188)    at org.apache.solr.search.FunctionRangeQParserPlugin.parse(FunctionRangeQParserPlugin.java:53)    at org.apache.solr.search.QParser.getQuery(QParser.java:188)    ... (manually supressed for brevity)

       

      The backtrace is much bigger, I'm attaching the raw Solr response in JSON (which is truncated) in response-error.json, and the full error message in error_full.txt . Apparently there is an infinite loop on the error message that same 9 backtrace entries are repeated ad-infinitum, so I believe this is the reason the error message Solr gives is truncated.

      How to Reproduce the Error

      I was able to create an small reproducible example to replicate the error. It creates a collection with two fields, and index 2 example documents. I provide the bash scripts to create the collections, and also the script to make the query. These are the scripts:

      • create_example-solr_9_0.sh: creates the collection, the fields, schema and index example documents for Solr 9.0.
      • create_example-solr_9_1.sh: creates the collection, the fields, schema and index example documents for Solr 9.1.
      • run_query.sh: executes the query that will responde correctly on Solr 9.0, and will return a Java Stack Overflow error on Solr 9.1.

      I have created separated scripts for Solr 9.0 and Solr 9.1 because of the change on the parameters of the Dense Vector field, which when from codecFormat to knnAlgorithm. So the two scripts differ only when defyning the vector field type.

      Attachments

        1. run_query.sh
          0.2 kB
          Gabriel Magno
        2. create_example-solr_9_0.sh
          2 kB
          Gabriel Magno
        3. create_example-solr_9_1.sh
          2 kB
          Gabriel Magno
        4. error_full.txt
          62 kB
          Gabriel Magno
        5. response-error.json
          64 kB
          Gabriel Magno

        Issue Links

          Activity

            People

              Unassigned Unassigned
              gmagno Gabriel Magno
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 4h 20m
                  4h 20m