Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/my_dbug.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ extern void _db_unlock_file_(void);
extern FILE *_db_fp_(void);
extern void _db_flush_();

extern void parallel_reader_copy_dbug_keyword_list(CODE_STATE **dst_ptr, CODE_STATE **src_ptr);

extern void parallel_reader_reset_dbug_keyword_list(CODE_STATE **cs_ptr);

#ifdef __cplusplus

#if defined(__GNUC__)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SET SESSION txsql_parallel_copy_ddl=ON;
CREATE TABLE t1 (fld1 INT, fld2 DATETIME NOT NULL) ENGINE= INNODB;
INSERT INTO t1 VALUES(1, '2000-01-01');
INSERT INTO t1 VALUES(2, '2001-01-01');
INSERT INTO t1 VALUES(3, '2002-01-01');
ALTER TABLE t1 ADD INDEX idx_sale_month ((MONTH(fld2))), ALGORITHM= COPY;
ALTER TABLE t1 DROP INDEX idx_sale_month, ALGORITHM= COPY;
DROP TABLE t1;
13 changes: 13 additions & 0 deletions mysql-test/r/disable_parallel_copy_ddl_generated_column.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SET SESSION txsql_parallel_copy_ddl=ON;
CREATE TABLE t1 (
id INT PRIMARY KEY,
a INT,
b INT GENERATED ALWAYS AS (a + 1) VIRTUAL
) ENGINE=INNODB;
INSERT INTO t1 (id, a) VALUES (1, 10), (2, 20), (3, 30);
ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=COPY;
DROP TABLE t1;
CREATE TABLE t2 (id INT PRIMARY KEY, a INT) ENGINE=INNODB;
INSERT INTO t2 VALUES (1, 10), (2, 20), (3, 30);
ALTER TABLE t2 ADD COLUMN c INT, ALGORITHM=COPY;
DROP TABLE t2;
28 changes: 28 additions & 0 deletions mysql-test/r/issue2284_fts_trx_create_crash_parallel_copy_ddl.csi
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
CREATE TABLE articles (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(200),
content TEXT,
FULLTEXT INDEX ft_index (title, content) WITH PARSER ngram
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
drop procedure if exists populate;
create procedure populate(IN start INT, IN end INT)
begin
declare i int default start;
SET autocommit=0;
repeat
INSERT INTO articles (title, content) VALUES
('MySQL Full-Text Search', 'This article explains how to use full-text search in MySQL.'),
('Understanding MySQL', 'MySQL is a popular relational database management system.'),
('Advanced MySQL Techniques', 'Learn advanced techniques for optimizing MySQL performance.');
set i=i+1;
until i=end
end repeat;
SET autocommit=1;
end |
CALL populate(0, 10000);
set session debug = '+d,sync_fts_trx_create';
SET SESSION txsql_parallel_copy_ddl = ON;
ALTER TABLE articles ENGINE=innodb, algorithm=copy;
set session debug = '-d,sync_fts_trx_create';
drop table articles;
drop procedure populate;
28 changes: 28 additions & 0 deletions mysql-test/r/issue2284_fts_trx_create_crash_parallel_copy_ddl.ncdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
CREATE TABLE articles (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(200),
content TEXT,
FULLTEXT INDEX ft_index (title, content) WITH PARSER ngram
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
drop procedure if exists populate;
create procedure populate(IN start INT, IN end INT)
begin
declare i int default start;
SET autocommit=0;
repeat
INSERT INTO articles (title, content) VALUES
('MySQL Full-Text Search', 'This article explains how to use full-text search in MySQL.'),
('Understanding MySQL', 'MySQL is a popular relational database management system.'),
('Advanced MySQL Techniques', 'Learn advanced techniques for optimizing MySQL performance.');
set i=i+1;
until i=end
end repeat;
SET autocommit=1;
end |
CALL populate(0, 10000);
set session debug = '+d,sync_fts_trx_create';
SET SESSION txsql_parallel_copy_ddl = ON;
ALTER TABLE articles ENGINE=innodb, algorithm=copy;
set session debug = '-d,sync_fts_trx_create';
drop table articles;
drop procedure populate;
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
CREATE TABLE articles (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(200),
content TEXT,
FULLTEXT INDEX ft_index (title, content) WITH PARSER ngram
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
drop procedure if exists populate;
create procedure populate(IN start INT, IN end INT)
begin
declare i int default start;
SET autocommit=0;
repeat
INSERT INTO articles (title, content) VALUES
('MySQL Full-Text Search', 'This article explains how to use full-text search in MySQL.'),
('Understanding MySQL', 'MySQL is a popular relational database management system.'),
('Advanced MySQL Techniques', 'Learn advanced techniques for optimizing MySQL performance.');
set i=i+1;
until i=end
end repeat;
SET autocommit=1;
end |
CALL populate(0, 10000);
set session debug = '+d,sync_fts_trx_create';
SET SESSION txsql_parallel_copy_ddl = ON;
ALTER TABLE articles ENGINE=innodb, algorithm=copy;
set session debug = '-d,sync_fts_trx_create';
drop table articles;
drop procedure populate;
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
CREATE TABLE articles (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(200),
content TEXT,
FULLTEXT INDEX ft_index (title, content) WITH PARSER ngram
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
drop procedure if exists populate;
create procedure populate(IN start INT, IN end INT)
begin
declare i int default start;
SET autocommit=0;
repeat
INSERT INTO articles (title, content) VALUES
('MySQL Full-Text Search', 'This article explains how to use full-text search in MySQL.'),
('Understanding MySQL', 'MySQL is a popular relational database management system.'),
('Advanced MySQL Techniques', 'Learn advanced techniques for optimizing MySQL performance.');
set i=i+1;
until i=end
end repeat;
SET autocommit=1;
end |
CALL populate(0, 10000);
set session debug = '+d,sync_fts_trx_create';
SET SESSION txsql_parallel_copy_ddl = ON;
ALTER TABLE articles ENGINE=innodb, algorithm=copy;
set session debug = '-d,sync_fts_trx_create';
drop table articles;
drop procedure populate;
Binary file modified mysql-test/r/parallel_copy_alter_table.result
Binary file not shown.
21 changes: 21 additions & 0 deletions mysql-test/r/pcddl_trx_state_concurrency_issue3628.ncdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
SET SESSION txsql_parallel_copy_ddl=ON;
SET debug="+d,sync_row_mysql_handle_errors";
CREATE TABLE t1(id int primary key, v int);
drop procedure if exists insert_t1;
create procedure insert_t1(IN start INT, IN end INT)
begin
declare i int default start;
SET autocommit=0;
repeat
INSERT INTO t1 VALUES (i, i);
set i=i+1;
until i=end
end repeat;
SET autocommit=1;
end |
CALL insert_t1(0, 20000);
UPDATE t1 SET v = 2 WHERE id = 9999;
ALTER TABLE t1 ADD UNIQUE INDEX k_1(v), algorithm=copy;
ERROR 23000: Can't write; duplicate key in table '#sql-394247_31'
DROP TABLE t1;
DROP PROCEDURE insert_t1;
21 changes: 21 additions & 0 deletions mysql-test/r/pcddl_trx_state_concurrency_issue3628.ncdb_pq
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
SET SESSION txsql_parallel_copy_ddl=ON;
SET debug="+d,sync_row_mysql_handle_errors";
CREATE TABLE t1(id int primary key, v int);
drop procedure if exists insert_t1;
create procedure insert_t1(IN start INT, IN end INT)
begin
declare i int default start;
SET autocommit=0;
repeat
INSERT INTO t1 VALUES (i, i);
set i=i+1;
until i=end
end repeat;
SET autocommit=1;
end |
CALL insert_t1(0, 20000);
UPDATE t1 SET v = 2 WHERE id = 9999;
ALTER TABLE t1 ADD UNIQUE INDEX k_1(v), algorithm=copy;
ERROR 23000: Can't write; duplicate key in table '#sql-395365_31'
DROP TABLE t1;
DROP PROCEDURE insert_t1;
21 changes: 21 additions & 0 deletions mysql-test/r/pcddl_trx_state_concurrency_issue3628.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
SET SESSION txsql_parallel_copy_ddl=ON;
SET debug="+d,sync_row_mysql_handle_errors";
CREATE TABLE t1(id int primary key, v int);
drop procedure if exists insert_t1;
create procedure insert_t1(IN start INT, IN end INT)
begin
declare i int default start;
SET autocommit=0;
repeat
INSERT INTO t1 VALUES (i, i);
set i=i+1;
until i=end
end repeat;
SET autocommit=1;
end |
CALL insert_t1(0, 20000);
UPDATE t1 SET v = 2 WHERE id = 9999;
ALTER TABLE t1 ADD UNIQUE INDEX k_1(v), algorithm=copy;
ERROR 23000: Can't write; duplicate key in table '#sql-431ed_e'
DROP TABLE t1;
DROP PROCEDURE insert_t1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
SET SESSION txsql_parallel_copy_ddl=ON;

CREATE TABLE t1 (fld1 INT, fld2 DATETIME NOT NULL) ENGINE= INNODB;

INSERT INTO t1 VALUES(1, '2000-01-01');
INSERT INTO t1 VALUES(2, '2001-01-01');
INSERT INTO t1 VALUES(3, '2002-01-01');
ALTER TABLE t1 ADD INDEX idx_sale_month ((MONTH(fld2))), ALGORITHM= COPY;

--let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err
--let SEARCH_PATTERN= Executing non-parallel copy DDL when txsql_parallel_copy_ddl=ON
--source include/search_pattern_in_file.inc

ALTER TABLE t1 DROP INDEX idx_sale_month, ALGORITHM= COPY;

--let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err
--let SEARCH_PATTERN= \[TXSQL Parallel Copy DDL\] parallel_threads=
--source include/search_pattern_in_file.inc

DROP TABLE t1;
35 changes: 35 additions & 0 deletions mysql-test/t/disable_parallel_copy_ddl_generated_column.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
# Verify that parallel copy DDL falls back to single-threaded copy when the
# target table contains a generated column. These expressions share a single
# Item tree across per-thread TABLE copies, evaluating them in parallel
# workers causes data races (e.g. Item_func_regexp::m_facade).
#

SET SESSION txsql_parallel_copy_ddl=ON;

--let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err

CREATE TABLE t1 (
id INT PRIMARY KEY,
a INT,
b INT GENERATED ALWAYS AS (a + 1) VIRTUAL
) ENGINE=INNODB;

INSERT INTO t1 (id, a) VALUES (1, 10), (2, 20), (3, 30);
ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=COPY;

--let SEARCH_PATTERN= Executing non-parallel copy DDL when txsql_parallel_copy_ddl=ON
--source include/search_pattern_in_file.inc

DROP TABLE t1;

# Control: a plain table without any generated column must still take the
# parallel path.
CREATE TABLE t2 (id INT PRIMARY KEY, a INT) ENGINE=INNODB;
INSERT INTO t2 VALUES (1, 10), (2, 20), (3, 30);
ALTER TABLE t2 ADD COLUMN c INT, ALGORITHM=COPY;

--let SEARCH_PATTERN= \[TXSQL Parallel Copy DDL\] parallel_threads=
--source include/search_pattern_in_file.inc

DROP TABLE t2;
39 changes: 39 additions & 0 deletions mysql-test/t/issue2284_fts_trx_create_crash_parallel_copy_ddl.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
--source include/have_debug.inc

CONNECT (con1,localhost,root,,);

CREATE TABLE articles (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(200),
content TEXT,
FULLTEXT INDEX ft_index (title, content) WITH PARSER ngram
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

delimiter |;
drop procedure if exists populate;
create procedure populate(IN start INT, IN end INT)
begin
declare i int default start;
SET autocommit=0;
repeat
INSERT INTO articles (title, content) VALUES
('MySQL Full-Text Search', 'This article explains how to use full-text search in MySQL.'),
('Understanding MySQL', 'MySQL is a popular relational database management system.'),
('Advanced MySQL Techniques', 'Learn advanced techniques for optimizing MySQL performance.');
set i=i+1;
until i=end
end repeat;
SET autocommit=1;
end |
delimiter ;|

CALL populate(0, 10000);

set session debug = '+d,sync_fts_trx_create';
SET SESSION txsql_parallel_copy_ddl = ON;

ALTER TABLE articles ENGINE=innodb, algorithm=copy;

set session debug = '-d,sync_fts_trx_create';
drop table articles;
drop procedure populate;
Loading