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

Truncate partition with global index blocks inserts also during delete reorganization state #55819

Closed
mjonss opened this issue Sep 3, 2024 · 0 comments · Fixed by #55831
Closed
Assignees
Labels
type/enhancement The issue or PR belongs to an enhancement.

Comments

@mjonss
Copy link
Contributor

mjonss commented Sep 3, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant