Skip to content

Commit 2c1aaa6

Browse files
authored
MDEV-28854 Disallow INSERT DELAYED on Spider table
Spider supports (or at least allows) INSERT DELAYED but the documentation does not specify spider as a storage engine that supports "INSERT DELAYED". Also, although not mentioned in the documentation, "INSERT DELAYED" is not intended to be executed inside a transaction, as can be seen from the list of supported storage engines. The current implementation allows executing a delayed insert on a remote transactional table and this breaks the consistency ensured by the transaction. We too remove "internal_delayed", one of the Spider table parameters. Documentation says, > Whether to transmit existence of delay to remote servers when > executing an INSERT DELAYED statement on local server. This table parameter is only used for "INSERT DELAYED". Reviewed by: Nayuta Yanagisawa
1 parent 5feb60c commit 2c1aaa6

File tree

9 files changed

+71
-35
lines changed

9 files changed

+71
-35
lines changed

storage/spider/ha_spider.cc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,9 +1110,6 @@ THR_LOCK_DATA **ha_spider::store_lock(
11101110
case TL_READ_HIGH_PRIORITY:
11111111
high_priority = TRUE;
11121112
break;
1113-
case TL_WRITE_DELAYED:
1114-
insert_delayed = TRUE;
1115-
break;
11161113
case TL_WRITE_LOW_PRIORITY:
11171114
low_priority = TRUE;
11181115
break;
@@ -1222,7 +1219,6 @@ THR_LOCK_DATA **ha_spider::store_lock(
12221219
lock_type = TL_READ;
12231220
if (
12241221
lock_type >= TL_WRITE_CONCURRENT_INSERT && lock_type <= TL_WRITE &&
1225-
lock_type != TL_WRITE_DELAYED &&
12261222
!thd->in_lock_tables && !thd_tablespace_op(thd)
12271223
)
12281224
lock_type = TL_WRITE_ALLOW_WRITE;
@@ -1804,7 +1800,6 @@ int ha_spider::reset()
18041800
insert_with_update = FALSE;
18051801
low_priority = FALSE;
18061802
high_priority = FALSE;
1807-
insert_delayed = FALSE;
18081803
use_pre_call = FALSE;
18091804
use_pre_records = FALSE;
18101805
pre_bitmap_checked = FALSE;
@@ -9556,7 +9551,6 @@ ulonglong ha_spider::table_flags() const
95569551
HA_CAN_FULLTEXT |
95579552
HA_CAN_SQL_HANDLER |
95589553
HA_FILE_BASED |
9559-
HA_CAN_INSERT_DELAYED |
95609554
HA_CAN_BIT_FIELD |
95619555
HA_NO_COPY_ON_ALTER |
95629556
HA_BINLOG_ROW_CAPABLE |
@@ -13955,7 +13949,6 @@ int ha_spider::sync_from_clone_source(
1395513949
update_request = spider->update_request;
1395613950
lock_mode = spider->lock_mode;
1395713951
high_priority = spider->high_priority;
13958-
insert_delayed = spider->insert_delayed;
1395913952
low_priority = spider->low_priority;
1396013953
memcpy(conns, spider->conns,
1396113954
sizeof(SPIDER_CONN *) * share->link_count);
@@ -13997,7 +13990,6 @@ int ha_spider::sync_from_clone_source(
1399713990
update_request = spider->update_request;
1399813991
lock_mode = spider->lock_mode;
1399913992
high_priority = spider->high_priority;
14000-
insert_delayed = spider->insert_delayed;
1400113993
low_priority = spider->low_priority;
1400213994

1400313995
if ((error_num = spider_check_trx_and_get_conn(spider->trx->thd,

storage/spider/ha_spider.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ class ha_spider: public handler
168168
bool insert_with_update;
169169
bool low_priority;
170170
bool high_priority;
171-
bool insert_delayed;
172171
bool use_pre_call;
173172
bool use_pre_records;
174173
bool pre_bitmap_checked;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#
2+
# MDEV-28854 Spider: Disallow INSERT DELAYED on Spider table
3+
#
4+
for master_1
5+
for child2
6+
child2_1
7+
child2_2
8+
child2_3
9+
for child3
10+
connection child2_1;
11+
CREATE DATABASE auto_test_remote;
12+
USE auto_test_remote;
13+
CREATE TABLE tbl_a (id INT);
14+
connection master_1;
15+
CREATE DATABASE auto_test_local;
16+
USE auto_test_local;
17+
CREATE TABLE tbl_a (
18+
id INT
19+
) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='table "tbl_a", srv "s_2_1"';
20+
connection master_1;
21+
INSERT DELAYED INTO tbl_a VALUES (1);
22+
ERROR HY000: DELAYED option not supported for table 'tbl_a'
23+
connection master_1;
24+
DROP DATABASE IF EXISTS auto_test_local;
25+
connection child2_1;
26+
DROP DATABASE IF EXISTS auto_test_remote;
27+
for master_1
28+
for child2
29+
child2_1
30+
child2_2
31+
child2_3
32+
for child3
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
!include include/default_mysqld.cnf
2+
!include ../my_1_1.cnf
3+
!include ../my_2_1.cnf
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
--echo #
2+
--echo # MDEV-28854 Spider: Disallow INSERT DELAYED on Spider table
3+
--echo #
4+
5+
--disable_query_log
6+
--disable_result_log
7+
--source ../../t/test_init.inc
8+
--enable_result_log
9+
--enable_query_log
10+
11+
--connection child2_1
12+
CREATE DATABASE auto_test_remote;
13+
USE auto_test_remote;
14+
CREATE TABLE tbl_a (id INT);
15+
16+
--connection master_1
17+
CREATE DATABASE auto_test_local;
18+
USE auto_test_local;
19+
eval CREATE TABLE tbl_a (
20+
id INT
21+
) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_a", srv "s_2_1"';
22+
23+
--connection master_1
24+
--error ER_DELAYED_NOT_SUPPORTED
25+
INSERT DELAYED INTO tbl_a VALUES (1);
26+
27+
--connection master_1
28+
DROP DATABASE IF EXISTS auto_test_local;
29+
--connection child2_1
30+
DROP DATABASE IF EXISTS auto_test_remote;
31+
32+
--disable_query_log
33+
--disable_result_log
34+
--source ../t/test_deinit.inc
35+
--enable_query_log
36+
--enable_result_log

storage/spider/spd_db_conn.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#define SPIDER_DB_INSERT_IGNORE (1 << 1)
3434
#define SPIDER_DB_INSERT_LOW_PRIORITY (1 << 2)
3535
#define SPIDER_DB_INSERT_HIGH_PRIORITY (1 << 3)
36-
#define SPIDER_DB_INSERT_DELAYED (1 << 4)
3736

3837
#define SPIDER_SQL_OPEN_PAREN_STR "("
3938
#define SPIDER_SQL_OPEN_PAREN_LEN (sizeof(SPIDER_SQL_OPEN_PAREN_STR) - 1)
@@ -75,8 +74,6 @@
7574
#define SPIDER_SQL_HIGH_PRIORITY_LEN (sizeof(SPIDER_SQL_HIGH_PRIORITY_STR) - 1)
7675
#define SPIDER_SQL_LOW_PRIORITY_STR "low_priority "
7776
#define SPIDER_SQL_LOW_PRIORITY_LEN (sizeof(SPIDER_SQL_LOW_PRIORITY_STR) - 1)
78-
#define SPIDER_SQL_SQL_DELAYED_STR "delayed "
79-
#define SPIDER_SQL_SQL_DELAYED_LEN (sizeof(SPIDER_SQL_SQL_DELAYED_STR) - 1)
8077
#define SPIDER_SQL_SQL_IGNORE_STR "ignore "
8178
#define SPIDER_SQL_SQL_IGNORE_LEN (sizeof(SPIDER_SQL_SQL_IGNORE_STR) - 1)
8279
#define SPIDER_SQL_FROM_STR " from "

storage/spider/spd_db_mysql.cc

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8044,7 +8044,6 @@ int spider_mbase_handler::append_insert(
80448044
spider_string *str,
80458045
int link_idx
80468046
) {
8047-
SPIDER_SHARE *share = spider->share;
80488047
DBUG_ENTER("spider_mbase_handler::append_insert");
80498048
if (
80508049
(
@@ -8069,15 +8068,6 @@ int spider_mbase_handler::append_insert(
80698068
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
80708069
str->q_append(SPIDER_SQL_LOW_PRIORITY_STR, SPIDER_SQL_LOW_PRIORITY_LEN);
80718070
}
8072-
else if (spider->insert_delayed)
8073-
{
8074-
if (share->internal_delayed)
8075-
{
8076-
if (str->reserve(SPIDER_SQL_SQL_DELAYED_LEN))
8077-
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
8078-
str->q_append(SPIDER_SQL_SQL_DELAYED_STR, SPIDER_SQL_SQL_DELAYED_LEN);
8079-
}
8080-
}
80818071
else if (
80828072
spider->lock_type >= TL_WRITE &&
80838073
!spider->write_can_replace &&
@@ -14667,12 +14657,6 @@ int spider_mbase_copy_table::append_insert_str(
1466714657
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
1466814658
sql.q_append(SPIDER_SQL_LOW_PRIORITY_STR, SPIDER_SQL_LOW_PRIORITY_LEN);
1466914659
}
14670-
else if (insert_flg & SPIDER_DB_INSERT_DELAYED)
14671-
{
14672-
if (sql.reserve(SPIDER_SQL_SQL_DELAYED_LEN))
14673-
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
14674-
sql.q_append(SPIDER_SQL_SQL_DELAYED_STR, SPIDER_SQL_SQL_DELAYED_LEN);
14675-
}
1467614660
else if (insert_flg & SPIDER_DB_INSERT_HIGH_PRIORITY)
1467714661
{
1467814662
if (sql.reserve(SPIDER_SQL_HIGH_PRIORITY_LEN))

storage/spider/spd_include.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,6 @@ typedef struct st_spider_share
951951
int selupd_lock_mode;
952952
int query_cache;
953953
int query_cache_sync;
954-
int internal_delayed;
955954
int bulk_size;
956955
int bulk_update_mode;
957956
int bulk_update_size;

storage/spider/spd_table.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,7 +2035,6 @@ int spider_parse_connect_info(
20352035
share->selupd_lock_mode = -1;
20362036
share->query_cache = -1;
20372037
share->query_cache_sync = -1;
2038-
share->internal_delayed = -1;
20392038
share->bulk_size = -1;
20402039
share->bulk_update_mode = -1;
20412040
share->bulk_update_size = -1;
@@ -2259,7 +2258,6 @@ int spider_parse_connect_info(
22592258
SPIDER_PARAM_STR_LIST("hws", hs_write_socks);
22602259
#endif
22612260
SPIDER_PARAM_INT("isa", init_sql_alloc_size, 0);
2262-
SPIDER_PARAM_INT_WITH_MAX("idl", internal_delayed, 0, 1);
22632261
SPIDER_PARAM_LONGLONG("ilm", internal_limit, 0);
22642262
SPIDER_PARAM_LONGLONG("ios", internal_offset, 0);
22652263
SPIDER_PARAM_INT_WITH_MAX("iom", internal_optimize, 0, 1);
@@ -2484,8 +2482,6 @@ int spider_parse_connect_info(
24842482
"multi_split_read", multi_split_read, 0, 2147483647);
24852483
SPIDER_PARAM_INT_WITH_MAX(
24862484
"selupd_lock_mode", selupd_lock_mode, 0, 2);
2487-
SPIDER_PARAM_INT_WITH_MAX(
2488-
"internal_delayed", internal_delayed, 0, 1);
24892485
SPIDER_PARAM_INT_WITH_MAX(
24902486
"table_count_mode", table_count_mode, 0, 3);
24912487
SPIDER_PARAM_INT_WITH_MAX(
@@ -3809,8 +3805,6 @@ int spider_set_connect_info_default(
38093805
share->query_cache = 0;
38103806
if (share->query_cache_sync == -1)
38113807
share->query_cache_sync = 0;
3812-
if (share->internal_delayed == -1)
3813-
share->internal_delayed = 0;
38143808
if (share->bulk_size == -1)
38153809
share->bulk_size = 16000;
38163810
if (share->bulk_update_mode == -1)

0 commit comments

Comments
 (0)