Commit a7cf0db3 authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-21011 Table corruption reported for versioned partitioned table after...

MDEV-21011 Table corruption reported for versioned partitioned table after DELETE: "Found a misplaced row"

LIMIT history partitions cannot be checked by existing algorithm of
check_misplaced_rows() because working history partition is
incremented each time another one is filled. The existing algorithm
gets record and tries to decide partition id for it by
get_partition_id(). For LIMIT history it will just get first
non-filled partition.

To fix such partitions it is required to do REBUILD instead of REPAIR.
parent 6dd41e00
...@@ -583,3 +583,17 @@ x a ...@@ -583,3 +583,17 @@ x a
3 bar 3 bar
4 bar 4 bar
drop table t1; drop table t1;
#
# MDEV-21011 Table corruption reported for versioned partitioned table after DELETE: "Found a misplaced row"
#
create table t1 (a int) with system versioning
partition by system_time limit 3
(partition p1 history, partition p2 history, partition pn current);
insert into t1 values (1),(2),(3),(4);
delete from t1;
delete from t1;
check table t1;
Table Op Msg_type Msg_text
test.t1 check note Not supported for non-INTERVAL history partitions
test.t1 check note The storage engine for the table doesn't support check
drop table t1;
...@@ -531,4 +531,19 @@ update t1 set a= 'bar' limit 4; ...@@ -531,4 +531,19 @@ update t1 set a= 'bar' limit 4;
select * from t1; select * from t1;
drop table t1; drop table t1;
--echo #
--echo # MDEV-21011 Table corruption reported for versioned partitioned table after DELETE: "Found a misplaced row"
--echo #
create table t1 (a int) with system versioning
partition by system_time limit 3
(partition p1 history, partition p2 history, partition pn current);
insert into t1 values (1),(2),(3),(4);
delete from t1;
delete from t1;
check table t1;
# cleanup
drop table t1;
--source suite/versioning/common_finish.inc --source suite/versioning/common_finish.inc
...@@ -10697,8 +10697,8 @@ int ha_partition::indexes_are_disabled(void) ...@@ -10697,8 +10697,8 @@ int ha_partition::indexes_are_disabled(void)
@param repair If true, move misplaced rows to correct partition. @param repair If true, move misplaced rows to correct partition.
@return Operation status. @return Operation status.
@retval 0 Success @retval HA_ADMIN_OK Success
@retval != 0 Error @retval != HA_ADMIN_OK Error
*/ */
int ha_partition::check_misplaced_rows(uint read_part_id, bool do_repair) int ha_partition::check_misplaced_rows(uint read_part_id, bool do_repair)
...@@ -10712,6 +10712,17 @@ int ha_partition::check_misplaced_rows(uint read_part_id, bool do_repair) ...@@ -10712,6 +10712,17 @@ int ha_partition::check_misplaced_rows(uint read_part_id, bool do_repair)
DBUG_ASSERT(m_file); DBUG_ASSERT(m_file);
if (m_part_info->vers_info &&
read_part_id != m_part_info->vers_info->now_part->id &&
!m_part_info->vers_info->interval.is_set())
{
print_admin_msg(ha_thd(), MYSQL_ERRMSG_SIZE, "note",
table_share->db.str, table->alias,
opt_op_name[CHECK_PARTS],
"Not supported for non-INTERVAL history partitions");
DBUG_RETURN(HA_ADMIN_NOT_IMPLEMENTED);
}
if (do_repair) if (do_repair)
{ {
/* We must read the full row, if we need to move it! */ /* We must read the full row, if we need to move it! */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment