Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge fixes for PS-9144 and PS-9214 into 8.0 release tree. #5385

Merged
merged 2 commits into from
Sep 3, 2024
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
57 changes: 57 additions & 0 deletions mysql-test/suite/innodb/r/percona_alter_debug.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#
# Test for PS-9144 : Missing rows after ALGORITHM=INPLACE ALTER under
# same workload as PS-9092.
#
CREATE TABLE t1 (pk CHAR(5) PRIMARY KEY);
INSERT INTO t1 VALUES ('aaaaa'), ('bbbbb'), ('bbbcc'), ('ccccc'), ('ddddd'), ('eeeee');
set global innodb_purge_stop_now=ON;
DELETE FROM t1 WHERE pk = 'bbbcc';
connect con1, localhost, root,,;
SET DEBUG='+d,ddl_buf_add_two';
SET DEBUG_SYNC='ddl_bulk_inserter_latches_released SIGNAL latches_released WAIT_FOR go';
# Send ALTER TABLE INPLACE which rebuilds table.
ALTER TABLE t1 ENGINE=InnoDB, ALGORITHM=INPLACE;
connection default;
SET DEBUG_SYNC='now WAIT_FOR latches_released';
SET GLOBAL innodb_purge_run_now=ON;
SET DEBUG_SYNC='now SIGNAL go';
connection con1;
# Reap ALTER TABLE
# Before the fix row 'ddddd' was missing from the table after ALTER.
SELECT * FROM t1;
pk
aaaaa
bbbbb
ccccc
ddddd
eeeee
SET DEBUG='-d,ddl_buf_add_two';
disconnect con1;
connection default;
# Cleanup.
SET DEBUG_SYNC= 'RESET';
DROP TABLE t1;
#
# Test for PS-9214 : Alter table online results in "duplicate key"
# error on the primary key (only index).
#
CREATE TABLE t1 (pk CHAR(5) PRIMARY KEY);
INSERT INTO t1 VALUES ('aaaaa'), ('bbbbb'), ('ccccc'), ('ddddd'), ('eeeee');
connect con1, localhost, root,,;
SET DEBUG='+d,ddl_buf_add_two';
SET DEBUG_SYNC='ddl_bulk_inserter_latches_released SIGNAL latches_released WAIT_FOR go';
# Send ALTER TABLE INPLACE which rebuilds table.
ALTER TABLE t1 ENGINE=InnoDB, ALGORITHM=INPLACE;
connection default;
SET DEBUG_SYNC='now WAIT_FOR latches_released';
INSERT INTO t1 VALUES ('ccaaa');
SET DEBUG_SYNC='now SIGNAL go';
connection con1;
# Reap ALTER TABLE
# Before fix it failed with duplicate key error.
SET DEBUG='-d,ddl_buf_add_two';
disconnect con1;
connection default;
# Cleanup.
SET DEBUG_SYNC= 'RESET';
DROP TABLE t1;
78 changes: 78 additions & 0 deletions mysql-test/suite/innodb/t/percona_alter_debug.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Tests in this file use both debug-only facilities as well as debug sync point.
--source include/have_debug.inc
--source include/have_debug_sync.inc
--enable_connect_log

--echo #
--echo # Test for PS-9144 : Missing rows after ALGORITHM=INPLACE ALTER under
--echo # same workload as PS-9092.
--echo #
CREATE TABLE t1 (pk CHAR(5) PRIMARY KEY);
INSERT INTO t1 VALUES ('aaaaa'), ('bbbbb'), ('bbbcc'), ('ccccc'), ('ddddd'), ('eeeee');

set global innodb_purge_stop_now=ON;
DELETE FROM t1 WHERE pk = 'bbbcc';

--connect (con1, localhost, root,,)
SET DEBUG='+d,ddl_buf_add_two';
SET DEBUG_SYNC='ddl_bulk_inserter_latches_released SIGNAL latches_released WAIT_FOR go';
--echo # Send ALTER TABLE INPLACE which rebuilds table.
--send ALTER TABLE t1 ENGINE=InnoDB, ALGORITHM=INPLACE

--connection default
SET DEBUG_SYNC='now WAIT_FOR latches_released';
SET GLOBAL innodb_purge_run_now=ON;
--source include/wait_innodb_all_purged.inc
SET DEBUG_SYNC='now SIGNAL go';

--connection con1
--echo # Reap ALTER TABLE
--reap

--echo # Before the fix row 'ddddd' was missing from the table after ALTER.
SELECT * FROM t1;

SET DEBUG='-d,ddl_buf_add_two';

--disconnect con1
--source include/wait_until_disconnected.inc

--connection default
--echo # Cleanup.
SET DEBUG_SYNC= 'RESET';
DROP TABLE t1;

--echo #
--echo # Test for PS-9214 : Alter table online results in "duplicate key"
--echo # error on the primary key (only index).
--echo #
CREATE TABLE t1 (pk CHAR(5) PRIMARY KEY);
INSERT INTO t1 VALUES ('aaaaa'), ('bbbbb'), ('ccccc'), ('ddddd'), ('eeeee');

--connect (con1, localhost, root,,)
SET DEBUG='+d,ddl_buf_add_two';
SET DEBUG_SYNC='ddl_bulk_inserter_latches_released SIGNAL latches_released WAIT_FOR go';
--echo # Send ALTER TABLE INPLACE which rebuilds table.
--send ALTER TABLE t1 ENGINE=InnoDB, ALGORITHM=INPLACE

--connection default
SET DEBUG_SYNC='now WAIT_FOR latches_released';
INSERT INTO t1 VALUES ('ccaaa');
SET DEBUG_SYNC='now SIGNAL go';

--connection con1
--echo # Reap ALTER TABLE
--echo # Before fix it failed with duplicate key error.
--reap

SET DEBUG='-d,ddl_buf_add_two';

--disconnect con1
--source include/wait_until_disconnected.inc

--connection default
--echo # Cleanup.
SET DEBUG_SYNC= 'RESET';
DROP TABLE t1;

--disable_connect_log
1 change: 1 addition & 0 deletions storage/innobase/ddl/ddl0par-scan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ dberr_t Parallel_cursor::scan(Builders &builders) noexcept {
thread_ctx->get_state() != Parallel_reader::State::THREAD) {
thread_ctx->savepoint();
latches_released = true;
DEBUG_SYNC_C("ddl_bulk_inserter_latches_released");
}
return DB_SUCCESS;
});
Expand Down
Loading
Loading