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

NPE in Replica Placement Rules when using Overseer Role with other rules

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.2, 7.0
    • Fix Version/s: 6.4
    • Component/s: Rules, SolrCloud
    • Security Level: Public (Default Security Level. Issues are Public)
    • Labels:
      None

      Description

      The overseer role introduced in SOLR-9251 works well if there's only a single Rule for replica placement e.g.

      rule=role:!overseer

      but when combined with another rule, e.g.

      rule=role:!overseer&rule=host:*,shard:*,replica:<2

      it can result in a NullPointerException (in Rule.tryAssignNodeToShard)

      This happens because the code builds up a nodeVsTags map, but it only has entries for nodes that have values for all tags used among the rules. This means not enough information is available to other rules when they are being checked during replica assignment. In the example rules above, if we have a cluster of 12 nodes and only 3 are given the Overseer role, the others do not have any entry in the nodeVsTags map because they only have the host tag value and not the role tag value.

      Looking at the code in ReplicaAssigner.getTagsForNodes, it is explicitly only keeping entries that fulfil the constraint of having values for all tags used in the rules. Possibly this constraint was suitable when rules were originally introduced, but the Role tag (used for Overseers) is unlikely to be present for all nodes in the cluster, and similarly for sysprop tags which may or not be set for a node.

      My patch removes this constraint, so the nodeVsTags map contains everything known about all nodes, even if they have no value for a given tag. This allows the rule combination above to work, and doesn't appear to cause any problems with the code paths that use the nodeVsTags map. They handle null values quite well, and the tests pass.

        Attachments

        1. SOLR-9503.patch
          3 kB
          Tim Owen
        2. SOLR-9503.patch
          4 kB
          Tim Owen

          Activity

            People

            • Assignee:
              noble.paul Noble Paul
              Reporter:
              TimOwen Tim Owen
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: