[MDEV-29718] Spider: variable spider_same_server_link not functioning correctly Created: 2022-10-05  Updated: 2024-02-05  Resolved: 2024-01-10

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - Spider
Affects Version/s: 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11
Fix Version/s: 10.4.33, 10.5.24, 10.6.17, 10.11.7, 11.0.5, 11.1.4, 11.2.3

Type: Bug Priority: Major
Reporter: Roel Van de Paar Assignee: Yuchen Pei
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates

 Description   

With thanks to elenst and nayuta-yanagisawa.

In principle, it should not be possible to make a connection to the same local instance without setting spider_same_server_link to 1.

However, as seen in several recent bugs, it is possible to create a socket (and possibly a tcp) connection to the same local instance with this variable still set to 0/off (the default).

As a sidethought, when this is fixed, any testcase which does not have spider_same_server_link=1 set, may need to be updated.

Relevant code:

    if (!spider_param_same_server_link(thd))
    {
      if (!strcmp(tgt_host, my_localhost))
      {
        if (!strcmp(tgt_socket, *spd_mysqld_unix_port))
        {
          my_printf_error(ER_SPIDER_SAME_SERVER_LINK_NUM,
            ER_SPIDER_SAME_SERVER_LINK_STR1, MYF(0),
            tgt_host, tgt_socket);
          DBUG_RETURN(ER_SPIDER_SAME_SERVER_LINK_NUM);
        }
      } else if (!strcmp(tgt_host, "127.0.0.1") ||
        !strcmp(tgt_host, glob_hostname))
      {
        if (tgt_port == (long) *spd_mysqld_port)
        {
          my_printf_error(ER_SPIDER_SAME_SERVER_LINK_NUM,
            ER_SPIDER_SAME_SERVER_LINK_STR2, MYF(0),
            tgt_host, tgt_port);
          DBUG_RETURN(ER_SPIDER_SAME_SERVER_LINK_NUM);
        }
      }
    }



 Comments   
Comment by Roel Van de Paar [ 2022-10-05 ]

Another item to consider here, again with thanks to elenst:

For the final test cases in the regression suite it may be best to switch them to host/port to allow running Spider tests on Windows, assuming socket does not work there. It is possible that some (Spider/MTR) mechanism exists to make the socket based tests work on Windows, but it is unlikely and needs to be checked.

Comment by Yuchen Pei [ 2023-12-15 ]

Hi holyfoot, ptal thanks

upstream/bb-10.4-mdev-29718 5f02c65d468fa28be4cdc71ba5a415c76f3a0814
MDEV-29718 Fix spider detection of same data node server
 
When the host is not specified, it defaults to localhost.

11.0 patch:

c9bc42416af upstream/bb-11.0-mdev-29718 MDEV-29718 Fix spider detection of same data node server

Comment by Alexey Botchkov [ 2024-01-06 ]

ok to push.

Comment by Yuchen Pei [ 2024-01-10 ]

thanks for the review - pushed bc3d416a17c9d35382f2db6387e51619e80c59da to 10.4

Generated at Thu Feb 08 10:10:45 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.