[MDEV-33125] CHECK TABLE does not recognize corruption after EXCHANGE WITHOUT VALIDATION on system-time partitioning Created: 2023-12-27  Updated: 2024-01-08

Status: Open
Project: MariaDB Server
Component/s: Partitioning, Versioned Tables
Affects Version/s: 11.4.0
Fix Version/s: 11.4

Type: Bug Priority: Critical
Reporter: Elena Stepanova Assignee: Aleksey Midenkov
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-22164 WITHOUT VALIDATION for EXCHANGE PARTI... Closed

 Description   

For a table with partitioning by system time of the limit kind, when a history partition gets rows with the current system time (via EXCHANGE .. WITHOUT VALIDATION), CHECK TABLE does not recognize the problem, and thus REPAIR doesn't fix it, current rows stay in the history partition and remain invisible.

--source include/have_partition.inc
 
create or replace table t1 (a int) with system versioning
partition by system_time limit 100 (p0 history, pn current);
insert into t1 (a) values (1),(2);
 
create or replace table t2 (a int) with system versioning;
insert into t2 (a) values (3),(4);
 
--error ER_ROW_DOES_NOT_MATCH_PARTITION
alter table t1 exchange partition p0 with table t2;
--error ER_ROW_DOES_NOT_MATCH_PARTITION
alter table t1 exchange partition p0 with table t2 with validation;
alter table t1 exchange partition p0 with table t2 without validation;
 
check table t1 extended;
repair table t1;
alter table t1 repair partition p0;
 
select a, row_start, row_end from t1;
select a, row_start, row_end from t1 for system_time all;
 
# Cleanup
drop table t1, t2;

11.4 5462b61b0c3ae59d3996018d7da34220460baf46

alter table t1 exchange partition p0 with table t2 without validation;
check table t1 extended;
Table	Op	Msg_type	Msg_text
test.t1	check	status	OK
repair table t1;
Table	Op	Msg_type	Msg_text
test.t1	repair	status	OK
alter table t1 repair partition p0;
Table	Op	Msg_type	Msg_text
test.t1	repair	status	OK
select a, row_start, row_end from t1;
a	row_start	row_end
1	2023-12-27 02:54:10.844545	2038-01-19 05:14:07.999999
2	2023-12-27 02:54:10.844545	2038-01-19 05:14:07.999999
select a, row_start, row_end from t1 for system_time all;
a	row_start	row_end
3	2023-12-27 02:54:10.882805	2038-01-19 05:14:07.999999
4	2023-12-27 02:54:10.882805	2038-01-19 05:14:07.999999
1	2023-12-27 02:54:10.844545	2038-01-19 05:14:07.999999
2	2023-12-27 02:54:10.844545	2038-01-19 05:14:07.999999

alter table t1 rebuild partition p0 is not included in the above test case, as it causes the error on a non-debug build

'alter table t1 rebuild partition p0' failed: ER_OPEN_AS_READONLY (1036): Table './test/t1.MYI' is read only

and an assertion failure similar to MDEV-20498 on a debug build (but with MyISAM).
I suppose anything can be expected since the table is already invalid, thus this report is not about errors which REBUILD produces, but about not being able to repair the table.


Generated at Thu Feb 08 10:36:34 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.