Skip to content

[BUG] isDataNode method in DiscoveryNode returns true for any node which can contain data #17706

@vinaykpud

Description

@vinaykpud

Describe the bug

Context

As part of discussion in #17422 issue we have now two new types of node roles : search and warm. Here is the PRs #17573 and #17620. We already have data role.

DiscoveryNodeRole has a boolean property canContainData which is true for search and warm nodes.

  1. public static final DiscoveryNodeRole DATA_ROLE = new DiscoveryNodeRole("data", "d", true) {
  2. public static final DiscoveryNodeRole SEARCH_ROLE = new DiscoveryNodeRole("search", "s", true) {
  3. public static final DiscoveryNodeRole WARM_ROLE = new DiscoveryNodeRole("warm", "w", true) {

for all the other roles we have canContainData is false.

Issue

isDataNode() method in DiscoveryNode class decides if its data node based on the canContainData property of the DiscoveryNodeRole, as shown bellow:

public static boolean isDataNode(final Settings settings) {
return getRolesFromSettings(settings).stream().anyMatch(DiscoveryNodeRole::canContainData);
}

In DiscoveryNodes it uses the isDataNode() method to construct dataNodesBuilder map.

if (nodeEntry.getValue().isDataNode()) {
dataNodesBuilder.put(nodeEntry.getKey(), nodeEntry.getValue());
}

So when we add search or warm node, they also counted as data nodes.

Solution

So we need to refactor to have two methods like this and use it accordingly depending on the usecase:

  1. canContainData : Checks if the node with any role can contain data
  2. isDataNode() : Checks if the node has data role

Before we can make above changes/refactor, I am trying to understand if we need to consider impact on any other components

@Bukhtawar @gbbafna @mch2 @andrross

Related component

Cluster Manager

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions