Log Not enough master nodes discovered during pinging – How To Solve Related Issues


Log Not enough master nodes discovered during pinging – How To Solve Related Issues

Opster Team

April-20, Version: 1.7-8.0

 

Before you begin reading this guide, we recommend you try running the Elasticsearch Error Check-Up which can resolve issues that cause many errors.

This guide will help you check for common problems that cause the log ” not enough master nodes discovered during pinging ” to appear. It’s important to understand the issues related to the log, so to get started, read the general overview on common issues and tips related to the Elasticsearch concepts: discovery and master.

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) :




 

Optimize Elasticsearch Performance

Try The Tool