Skip to content

Commit

Permalink
MDEV-29718 Fix spider detection of same data node server
Browse files Browse the repository at this point in the history
When the host is not specified, it defaults to localhost.
  • Loading branch information
mariadb-YuchenPei committed Jan 10, 2024
1 parent eabc74a commit bc3d416
Show file tree
Hide file tree
Showing 33 changed files with 41 additions and 2 deletions.
4 changes: 4 additions & 0 deletions storage/spider/mysql-test/spider/bugfix/r/mdev_26151.result
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ for child2
for child3
set @old_spider_bgs_mode= @@spider_bgs_mode;
set session spider_bgs_mode=1;
set spider_same_server_link=1;
set @old_spider_same_server_link=@@global.spider_same_server_link;
set global spider_same_server_link=1;
CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table td (a int, PRIMARY KEY (a));
create table ts (a int, PRIMARY KEY (a)) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv_mdev_26151",TABLE "td", casual_read "3"';
Expand All @@ -26,6 +29,7 @@ min(a)
drop table td, ts;
drop server srv_mdev_26151;
set session spider_bgs_mode=@old_spider_bgs_mode;
set global spider_same_server_link=@old_spider_same_server_link;
for master_1
for child2
for child3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ for master_1
for child2
for child3
set global query_cache_type= on;
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t2 (c int);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
# testing monitoring_*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER s FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER s FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t1 (a INT);
CREATE TABLE t2 (b INT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t1 (c int);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t (a INT) ENGINE=Spider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t1 (c int);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t (c BLOB) ENGINE=InnoDB;
CREATE TABLE ts (c BLOB) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE "t"';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ for master_1
for child2
for child3
SET @old_spider_read_only_mode = @@session.spider_read_only_mode;
set spider_same_server_link=1;
CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
set session spider_read_only_mode = default;
create table t2 (c int);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t1 ( a bigint(20) NOT NULL, b bigint(20) DEFAULT 0, PRIMARY KEY (a));
CREATE TABLE t2 ( a bigint(20) NOT NULL, b bigint(20) DEFAULT 0, PRIMARY KEY (a)) ENGINE=SPIDER COMMENT='srv "srv", WRAPPER "mysql", TABLE "t1"';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
set session spider_delete_all_rows_type=0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t2 (c varchar(16));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t1 (c int);
create table t2 (d int);
Expand Down
1 change: 1 addition & 0 deletions storage/spider/mysql-test/spider/bugfix/r/subquery.result
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
for master_1
for child2
for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t1 (c1 int);
create table t2 (c2 int);
Expand Down
5 changes: 5 additions & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_26151.test
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
--let $srv=srv_mdev_26151
set @old_spider_bgs_mode= @@spider_bgs_mode;
set session spider_bgs_mode=1;
set spider_same_server_link=1;
set @old_spider_same_server_link=@@global.spider_same_server_link;
set global spider_same_server_link=1;

evalp CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');

# casual_read != 0 && casual_read != 1
Expand Down Expand Up @@ -42,6 +46,7 @@ drop table td, ts;

eval drop server $srv;
set session spider_bgs_mode=@old_spider_bgs_mode;
set global spider_same_server_link=@old_spider_same_server_link;

--disable_query_log
--disable_result_log
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#set @@global.debug_dbug="d:t:i:o,mysqld.trace";

set global query_cache_type= on;
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t2 (c int);
Expand Down
1 change: 1 addition & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_28856.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

# This test covers some table params under consideration for inclusion
# in the engine-defined options to be implemented in MDEV-28856.
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');

Expand Down
1 change: 1 addition & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_28998.test
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ if (`select not(count(*)) from information_schema.system_variables where variabl
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER s FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');

CREATE TABLE t1 (a INT);
Expand Down
1 change: 1 addition & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_29163.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER s FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');

CREATE TABLE t1 (a INT);
Expand Down
1 change: 1 addition & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_29456.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
--enable_result_log
--enable_query_log

set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');

Expand Down
1 change: 1 addition & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_29963.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
--enable_result_log
--enable_query_log

set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');

Expand Down
1 change: 1 addition & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_30014.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
--enable_result_log
--enable_query_log

set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');

Expand Down
1 change: 1 addition & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_30392.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');

CREATE TABLE t1 (a INT);
Expand Down
1 change: 1 addition & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_31338.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
--enable_result_log
--enable_query_log

set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t (c BLOB) ENGINE=InnoDB;
CREATE TABLE ts (c BLOB) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE "t"';
Expand Down
1 change: 1 addition & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_31524.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

--let $srv=srv_mdev_31524
SET @old_spider_read_only_mode = @@session.spider_read_only_mode;
set spider_same_server_link=1;
evalp CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');

# when the user does not set var nor the table option, the default
Expand Down
1 change: 1 addition & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_31645.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');

CREATE TABLE t1 ( a bigint(20) NOT NULL, b bigint(20) DEFAULT 0, PRIMARY KEY (a));
Expand Down
1 change: 1 addition & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_31996.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
--enable_result_log
--enable_query_log

set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');

Expand Down
1 change: 1 addition & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_32986.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
--enable_result_log
--enable_query_log

set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t1 (c int);
create table t2 (d int);
Expand Down
1 change: 1 addition & 0 deletions storage/spider/mysql-test/spider/bugfix/t/subquery.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t1 (c1 int);
create table t2 (c2 int);
Expand Down
4 changes: 2 additions & 2 deletions storage/spider/spd_db_mysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1985,7 +1985,7 @@ int spider_db_mbase::connect(

if (!spider_param_same_server_link(thd))
{
if (!strcmp(tgt_host, my_localhost))
if (!strcmp(tgt_host, my_localhost) || !tgt_host || !tgt_host[0])
{
if (!strcmp(tgt_socket, *spd_mysqld_unix_port))
{
Expand All @@ -1995,7 +1995,7 @@ int spider_db_mbase::connect(
DBUG_RETURN(ER_SPIDER_SAME_SERVER_LINK_NUM);
}
} else if (!strcmp(tgt_host, "127.0.0.1") ||
!strcmp(tgt_host, glob_hostname))
!strcmp(tgt_host, glob_hostname) || !tgt_host || !tgt_host[0])
{
if (tgt_port == (long) *spd_mysqld_port)
{
Expand Down

0 comments on commit bc3d416

Please sign in to comment.