getaddrinfo failure

Bug #1250805 reported by Raghavendra D Prabhu
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MySQL patches by Codership
Status tracked in 5.6
5.6
Fix Released
Medium
Alex Yurchenko
Percona XtraDB Cluster moved to https://jira.percona.com/projects/PXC
Status tracked in 5.6
5.5
Fix Released
High
Raghavendra D Prabhu
5.6
Fix Released
High
Unassigned

Bug Description

wsrep_check_ip (added in wsrep-24 and wsrep-56) fails on Debian as:

2013-11-13 16:04:07 7627 [ERROR] WSREP: getaddrinfo() failed on '*': -2 (Name or service not known)
2013-11-13 16:04:07 7627 [ERROR] WSREP: Networking not configured, cannot receive state transfer.

This is because the default value of bind_address (if not set) is '*'

mysql> show global variables like '%bind_address%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| bind_address | * |
+---------------+-------+
1 row in set (0.01 sec)

=============================

Note this won't occur if wsrep-node-address is provided.

Also, this didn't occur with wsrep-23 branch.

description: updated
Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

This is how the code looks in activate_tcp_port:

  if (strcasecmp(my_bind_addr_str, MY_BIND_ALL_ADDRESSES) == 0)
  {
    /*
      That's the case when bind-address is set to a special value ('*'),
      meaning "bind to all available IP addresses". If the box supports
      the IPv6 stack, that means binding to '::'. If only IPv4 is available,
      bind to '0.0.0.0'.
    */

    bool ipv6_available= false;

    if (!getaddrinfo(ipv6_all_addresses, port_buf, &hints, &ai))
    {
      /*
        IPv6 might be available (the system might be able to resolve an IPv6
        address, but not be able to create an IPv6-socket). Try to create a
        dummy IPv6-socket. Do not instrument that socket by P_S.
      */

      MYSQL_SOCKET s= mysql_socket_socket(0, AF_INET6, SOCK_STREAM, 0);

      ipv6_available= mysql_socket_getfd(s) != INVALID_SOCKET;

      mysql_socket_close(s);
    }

    if (ipv6_available)
    {
      sql_print_information("IPv6 is available.");

      // Address info (ai) for IPv6 address is already set.

      bind_address_str= ipv6_all_addresses;
    }
    else
    {
      sql_print_information("IPv6 is not available.");

      // Retrieve address info (ai) for IPv4 address.

      if (getaddrinfo(ipv4_all_addresses, port_buf, &hints, &ai))
      {
        sql_perror(ER_DEFAULT(ER_IPSOCK_ERROR));
        sql_print_error("Can't start server: cannot resolve hostname!");
        unireg_abort(1);
      }

      bind_address_str= ipv4_all_addresses;
    }
  }
  else
  {
    if (getaddrinfo(my_bind_addr_str, port_buf, &hints, &ai))
    {
      sql_perror(ER_DEFAULT(ER_IPSOCK_ERROR)); /* purecov: tested */
      sql_print_error("Can't start server: cannot resolve hostname!");
      unireg_abort(1); /* purecov: tested */
    }

    bind_address_str= my_bind_addr_str;
  }

=============================================================

It should be handled similarly in wsrep_check_ip.

=================================================
/**
  MY_BIND_ALL_ADDRESSES defines a special value for the bind-address option,
  which means that the server should listen to all available network addresses,
  both IPv6 (if available) and IPv4.

  Basically, this value instructs the server to make an attempt to bind the
  server socket to '::' address, and rollback to '0.0.0.0' if the attempt fails.
*/
const char *MY_BIND_ALL_ADDRESSES= "*";

=====================================================

Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

I cleaned up this part but wsrep-node-address is still required which brings up the question, why is 0.0.0.0 not allowed for wsrep?

from galera:

=========================

            if (host == "0.0.0.0" || host == "0:0:0:0:0:0:0:0" || host == "::")
            {
                gu_throw_error(EINVAL) << "Bad value for 'node_address': '"
                                       << host << '\'';
            }

=======================

If this is allowed then all the wsrep-node-address noise can be avoided (and all the ifconfig called from mysqld!). mysqld can listen on 0.0.0.0 fine, why not wsrep/galera?

Revision history for this message
Alex Yurchenko (ayurchen) wrote :

As discussed in chat, wsrep-node-address variable is not to bind listening socket. It is to tell other nodes how they can reach this node (specifically to perform state transfer), and/or to show in wsrep_incoming_addresses status variable.

In other words, it is an address by which node should be addressed. So it can't be trivial.

Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :
Revision history for this message
Alex Yurchenko (ayurchen) wrote :
Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PXC-982

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.