Solr
  1. Solr
  2. SOLR-6550

Provide simple mechanism for passing additional metadata / context about a server-side SolrException back to the client-side

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.10.2, 5.0
    • Component/s: SolrJ
    • Labels:
      None

      Description

      While trying to resolve SOLR-6511, it became apparent that I didn't have a good way to convey more information about a particular error occurring on the server-side using SolrException. The specific situation I encountered is a replica took over as leader, but the previous leader wasn't aware of that yet (due to a Zk session expiration). So when the previous leader (the one that experienced the Zk session expiration) sent an update request with FROMLEADER, the new leader rejected the request with a SolrException. Ideally, we want the new leader to be able to say "you're not the leader anymore" and for the previous leader to fail the request in a specific way; see SOLR-6511 for more background on this scenario.

      My first inclination was to just extend SolrException and throw a LeaderChangedException and have the client behave accordingly but then I discovered that CUSS just takes the status code and error message and reconstructs a new SolrException (on the client side). HttpSolrServer does the same thing when creating a RemoteSolrException. So the fact that the server-side throw a LeaderChangeException is basically lost in translation.

      I'm open to other suggestions but here's my approach so far:

      Add a NamedList<String> metadata field to the SolrException class.
      If a server-side component wants to add additional context / metadata, then it will call: solrExc.setMetadata("name", "value);

      When the response is being marshaled into the wire format, ResponseUtils will include the metadata if available. On the client side, when the response is processed, the metadata gets included into the new SolrException (in CUSS) or RemoteSolrException (HttpSolrServer). It's up to the client to dig into the metadata to take additional steps as I'll be doing in DistributedUpdateProcessor.

      1. SOLR-6550.patch
        5 kB
        Timothy Potter

        Issue Links

          Activity

          Hide
          Timothy Potter added a comment -

          Patch for the approach I described above.

          Show
          Timothy Potter added a comment - Patch for the approach I described above.
          Hide
          ASF subversion and git services added a comment -

          Commit 1627154 from Timothy Potter in branch 'dev/trunk'
          [ https://svn.apache.org/r1627154 ]

          SOLR-6550: Provide simple mechanism for passing additional metadata / context about a server-side SolrException back to the client-side

          Show
          ASF subversion and git services added a comment - Commit 1627154 from Timothy Potter in branch 'dev/trunk' [ https://svn.apache.org/r1627154 ] SOLR-6550 : Provide simple mechanism for passing additional metadata / context about a server-side SolrException back to the client-side
          Hide
          ASF subversion and git services added a comment -

          Commit 1628988 from Timothy Potter in branch 'dev/branches/branch_5x'
          [ https://svn.apache.org/r1628988 ]

          SOLR-6550: Provide simple mechanism for passing additional metadata / context about a server-side SolrException back to the client-side

          Show
          ASF subversion and git services added a comment - Commit 1628988 from Timothy Potter in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1628988 ] SOLR-6550 : Provide simple mechanism for passing additional metadata / context about a server-side SolrException back to the client-side
          Hide
          ASF subversion and git services added a comment -

          Commit 1628991 from Timothy Potter in branch 'dev/branches/branch_5x'
          [ https://svn.apache.org/r1628991 ]

          SOLR-6550: mention this fix in other changes section of solr/CHANGES.txt

          Show
          ASF subversion and git services added a comment - Commit 1628991 from Timothy Potter in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1628991 ] SOLR-6550 : mention this fix in other changes section of solr/CHANGES.txt
          Hide
          ASF subversion and git services added a comment -

          Commit 1628992 from Timothy Potter in branch 'dev/trunk'
          [ https://svn.apache.org/r1628992 ]

          SOLR-6550: mention this fix in other changes section of solr/CHANGES.txt

          Show
          ASF subversion and git services added a comment - Commit 1628992 from Timothy Potter in branch 'dev/trunk' [ https://svn.apache.org/r1628992 ] SOLR-6550 : mention this fix in other changes section of solr/CHANGES.txt
          Hide
          ASF subversion and git services added a comment -

          Commit 1630164 from Timothy Potter in branch 'dev/branches/lucene_solr_4_10'
          [ https://svn.apache.org/r1630164 ]

          SOLR-6550: backport to 4_10 branch so we can backport SOLR-6511

          Show
          ASF subversion and git services added a comment - Commit 1630164 from Timothy Potter in branch 'dev/branches/lucene_solr_4_10' [ https://svn.apache.org/r1630164 ] SOLR-6550 : backport to 4_10 branch so we can backport SOLR-6511

            People

            • Assignee:
              Timothy Potter
              Reporter:
              Timothy Potter
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development