Not enough master nodes discovered during pinging found but needed pinging again – How to solve this Elasticsearch error

Opster Team

Aug-23, Version: 6.8-7.15

Briefly, this error occurs when Elasticsearch cannot find the required number of master-eligible nodes for forming a cluster. This could be due to network issues, incorrect configuration, or nodes being down. To resolve this, ensure all nodes are running and network connectivity is stable. Check the configuration files for each node, ensuring they are correctly set to allow discovery. Also, consider increasing the ‘discovery.zen.minimum_master_nodes’ setting to a suitable value.

We recommend you run Elasticsearch Error Check-Up which can resolve issues that cause many errors.

Advanced users might want to skip right to the common problems section in each concept or try running the Check-Up which analyses ES to pinpoint the cause of many errors and provides suitable actionable recommendations how to resolve them (free tool that requires no installation).

Important Note:- This log is for Elasticsearch versions before 7.X. beginning from 7.X Elasticsearch uses a new cluster coordination technique explained in this official ES blog.

Overview

Before Elasticsearch’s current major version(7.X), Elasticsearch used the Zen discovery module for discovery and cluster formation. This module uses two main configs in production, to create a cluster and elect the master nodes.

 discovery.zen.ping.unicast.hosts: //list of all the nodes participate in the cluster
discovery.zen.minimum_master_nodes: //Minimum no of master nodes in your cluster.. 

Troubleshooting steps:

  1. A warning log would mention how many master nodes were found and how many are required, for example, the warning log below shows a total of 2 master nodes required and no master nodes found. The number of total master nodes is dependent on the config discovery.zen.minimum_master_nodes.   
     not enough master nodes discovered during pinging (found [[]], but needed [2]), pinging again 
  2. Check how many master nodes are configured in your cluster by default., Eevery node can act as the master node, and you can explicitly disable it using node.master : false in the particular node’s elasticsearch.yml.
  3. The above step helps to determine how many nodes are eligible to become masters, and if this is less than the discovery.zen.minimum_master_nodes, then the cluster won’t able to choose the master node.
  4. Sometimes due to network issues or some other issue, some eligible master nodes are not connected to other nodes and to troubleshoot this, you can enable the TRACE logging by adding the below line in elasticsearch.yml.
 logger.org.elasticsearch.discovery: TRACE 

This gives more information on the cause, like in the sample TRACE log below for Zen discovery, which mentions that another master eligible node is not reachable (as it hadn’t been started)., The IP was mentioned in the discovery.zen.ping.unicast.hosts:

 [2020-03-20T06:35:00,218][TRACE][o.e.d.z.UnicastZenPing ] [] [10] failed to ping {#zen_unicast_172.31.36.118_0#}{BvhuywOqT1qf5Jxwn5zcsw}{172.31.36.118}{172.31.36.118:9300}
org.elasticsearch.transport.ConnectTransportException: [][172.31.36.118:9300] connect_timeout[3s]

Log Context

Log “not enough master nodes discovered during pinging (found [{}]; but needed [{}]); pinging again” classname is ZenDiscovery.java.
We extracted the following from Elasticsearch source code for those seeking an in-depth context :

                final ElectMasterService.MasterCandidate winner = electMaster.electMaster(masterCandidates);
                logger.trace("candidate {} won election"; winner);
                return winner.getNode();
            } else {
                // if we don't have enough master nodes; we bail; because there are not enough master to elect from
                logger.warn("not enough master nodes discovered during pinging (found [{}]; but needed [{}]); pinging again";
                            masterCandidates; electMaster.minimumMasterNodes());
                return null;
            }
        } else {
            assert activeMasters.contains(localNode) == false :

 

 [ratemypost]