[MDEV-12389] ADD CHECK leaves an orphaned .par file Created: 2017-03-28  Updated: 2020-08-25  Resolved: 2017-05-24

Status: Closed
Project: MariaDB Server
Component/s: Partitioning, Storage Engine - InnoDB
Affects Version/s: 10.0, 10.1, 10.1.21
Fix Version/s: 10.1.24, 10.2.7

Type: Bug Priority: Major
Reporter: Geoff Montee (Inactive) Assignee: Sergei Golubchik
Resolution: Fixed Votes: 1
Labels: check_constraints, innodb, partitioning

Issue Links:
Relates
relates to MDEV-12923 MyISAM allows CHECK constraint violat... Closed

 Description   

Executing ALTER TABLE ADD CHECK on a partitioned InnoDB table leaves an orphaned .par file behind. To reproduce, execute the following:

drop database if exists orphan_par_test;
create database orphan_par_test;
use orphan_par_test;
drop table if exists t;
create table t(id int, d DATE NOT NULL, manual_override BOOL NOT NULL DEFAULT 0, primary key(id,d))
PARTITION BY RANGE COLUMNS (d) ( 
PARTITION p20161017 VALUES LESS THAN ('2016-10-18'),
PARTITION p20161018 VALUES LESS THAN ('2016-10-19'));
ALTER TABLE t ADD CHECK (b IN (0, 1));

And then execute the following:

drop database orphan_par_test;

The statement will fail with the following error:

MariaDB [orphan_par_test]> drop database orphan_par_test;
ERROR 1010 (HY000): Error dropping database (can't rmdir './orphan_par_test', errno: 39 "Directory not empty")

And we can see that the directory is non-empty because of the orphaned .par file:

[ec2-user@ip-172-30-0-32 ~]$ sudo ls -l /var/lib/mysql/orphan_par_test/
total 4
-rw-rw---- 1 mysql mysql 48 Mar 28 19:01 #sql-32a_6.par



 Comments   
Comment by Elena Stepanova [ 2017-05-01 ]

--source include/have_innodb.inc
--source include/have_partition.inc
 
--let $datadir=`SELECT @@datadir`
 
drop database if exists orphan_par_test;
create database orphan_par_test;
use orphan_par_test;
drop table if exists t;
create table t(id int, d DATE NOT NULL, b BOOL NOT NULL DEFAULT 0, primary key(id,d))
ENGINE=InnoDB
PARTITION BY RANGE COLUMNS (d) ( 
PARTITION p20161017 VALUES LESS THAN ('2016-10-18'),
PARTITION p20161018 VALUES LESS THAN ('2016-10-19'));
ALTER TABLE t ADD CHECK (b IN (0, 1));
--list_files $datadir/orphan_par_test 
drop database orphan_par_test;

10.0, 10.1 are affected, 10.2 is not.
GeoffMontee, do you need a fix for this in 10.1?

Generated at Thu Feb 08 07:57:20 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.