-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Labels
type/enhancementThe issue or PR belongs to an enhancement.The issue or PR belongs to an enhancement.
Description
Enhancement
ALTER TABLE t TRUNCATE PARTITION will block inserts to the truncated partition during both "delete only" and "delete reorganization" regardless if there is a duplicate key or not.
How to test:
-- client 1
create table t (a int primary key nonclustered global, b int) partition by hash (b) partitions 3;
insert into t values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6);
-- client 2
begin;
select count(*) from t;
-- client 1
alter table t truncate partition p0;
-- client 3
begin;
insert into t values (9,9); -- fails with "ERROR 8210 (HY000): the partition is in not in public"
select * from information_schema.DDL_JOBS where table_name = 't' order by job_id desc limit 1; -- shows "delete only" schema state
-- client 2
rollback;
begin;
insert into t values (12,12); -- fails with "ERROR 8210 (HY000): the partition is in not in public"
select * from information_schema.DDL_JOBS where table_name = 't' order by job_id desc limit 1; -- shows "delete only" schema state
-- client 3
rollback;
begin;
insert into t values (15,15); -- fails with "ERROR 8210 (HY000): the partition is in not in public"
select * from information_schema.DDL_JOBS where table_name = 't' order by job_id desc limit 1; -- shows "delete reorganization" schema state
-- client 2
rollback;
begin;
insert into t values (18,18);
select * from information_schema.DDL_JOBS where table_name = 't' order by job_id desc limit 1; -- shows "delete reorganization" schema state
-- client 3
rollback;
begin;
insert into t values (21,21); -- Finally succeeds!
select * from information_schema.DDL_JOBS where table_name = 't' order by job_id desc limit 1; -- shows "none" schema state, done state
-- client 2
insert into t values (24,24); -- Still fails with "ERROR 8210 (HY000): the partition is in not in public"
select * from information_schema.DDL_JOBS where table_name = 't' order by job_id desc limit 1; -- shows "none" schema state, done state
rollback; -- now client 1 will finish and the job will be synced
insert into t values (27,27); -- Finally succeeds!
select * from information_schema.DDL_JOBS where table_name = 't' order by job_id desc limit 1; -- shows "none" schema state, synced state
I would expect that during "delete reorganize" state, which can take a long time if the partition was big, that inserts/updates/deletes would work without errors (not even duplicate key errors).
During the first schema state "delete only" I would accept that "duplicate key" errors were given.
Metadata
Metadata
Assignees
Labels
type/enhancementThe issue or PR belongs to an enhancement.The issue or PR belongs to an enhancement.