You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ds...@apache.org on 2022/04/26 04:40:50 UTC

[solr] branch main updated: SOLR-16145: NPE fix in rejoinOverseerElection (#793)

This is an automated email from the ASF dual-hosted git repository.

dsmiley pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new ef2b725931d SOLR-16145: NPE fix in rejoinOverseerElection (#793)
ef2b725931d is described below

commit ef2b725931ddd547e08d0f13f96e985f22653e4a
Author: David Smiley <ds...@salesforce.com>
AuthorDate: Tue Apr 26 00:40:45 2022 -0400

    SOLR-16145: NPE fix in rejoinOverseerElection (#793)
    
    Fix very rare NPE in SolrCloud rejoinOverseerElection.
    Introduced by SOLR-13410
---
 solr/CHANGES.txt                                           |  2 ++
 solr/core/src/java/org/apache/solr/cloud/ZkController.java | 11 ++++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 859b669fb98..a4e38d5c021 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -65,6 +65,8 @@ Bug Fixes
 
 * SOLR-13044: Fix NPE during core close racing with index replication check.  (David Smiley, hossman)
 
+* SOLR-16145: Fix very rare NPE in SolrCloud rejoinOverseerElection. (David Smiley)
+
 * SOLR-16168: Spellcheck NPE if invalid dictionary name is provided (Kevin Risden)
 
 Other Changes
diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
index 0778f7e9b66..1a1d050941b 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
@@ -2346,15 +2346,16 @@ public class ZkController implements Closeable {
 
   public void rejoinOverseerElection(String electionNode, boolean joinAtHead) {
     try {
+      final ElectionContext context = overseerElector.getContext();
       if (electionNode != null) {
         // Check whether we came to this node by mistake
-        if (overseerElector.getContext() != null
-            && overseerElector.getContext().leaderSeqPath == null
-            && !overseerElector.getContext().leaderSeqPath.endsWith(electionNode)) {
+        if (context != null
+            && context.leaderSeqPath != null
+            && !context.leaderSeqPath.endsWith(electionNode)) {
           log.warn(
               "Asked to rejoin with wrong election node : {}, current node is {}",
               electionNode,
-              overseerElector.getContext().leaderSeqPath);
+              context.leaderSeqPath);
           // however delete it . This is possible when the last attempt at deleting the election
           // node failed.
           if (electionNode.startsWith(getNodeName())) {
@@ -2377,7 +2378,7 @@ public class ZkController implements Closeable {
           return;
         }
       } else {
-        overseerElector.retryElection(overseerElector.getContext(), joinAtHead);
+        overseerElector.retryElection(context, joinAtHead);
       }
     } catch (Exception e) {
       throw new SolrException(ErrorCode.SERVER_ERROR, "Unable to rejoin election", e);