Bug #18962 Partitions: Error on third ALTER TABLE t1 DROP PARTITION ..., crash
Submitted: 10 Apr 2006 15:19 Modified: 23 Apr 2006 3:04
Reporter: Matthias Leich Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Partitions Severity:S2 (Serious)
Version:5.1 OS:
Assigned to: Mikael Ronström CPU Architecture:Any

[10 Apr 2006 15:19] Matthias Leich
Description:
CREATE TABLE t1 (f_int INTEGER, f_varchar VARCHAR(30))
PARTITION BY RANGE(MOD(f_int,3)) 
SUBPARTITION BY HASH(f_int) SUBPARTITIONS 2
(PARTITION p0 VALUES LESS THAN (1),
 PARTITION p1 VALUES LESS THAN (2),
 PARTITION p2 VALUES LESS THAN (3),
 PARTITION p3 VALUES LESS THAN (4));

ALTER TABLE t1 DROP PARTITION p3;
ALTER TABLE t1 DROP PARTITION p1;
ALTER TABLE t1 DROP PARTITION p2;
-->ERROR HY000: 
     Error on delete of './test/t1#P#p2#SP#p1sp0.MYI' (Errcode: 2)
### But p1sp0.MYI belongs to the already removed partition p1 !!

### A directory listing shows, that the last statement did not remove
### any file belonging to the table t1.
###        t1#P#p0#SP#p0sp0.MYD
###        t1#P#p0#SP#p0sp0.MYI
###        t1#P#p0#SP#p0sp1.MYD
###        t1#P#p0#SP#p0sp1.MYI
###        t1#P#p2#SP#p2sp0.MYD
###        t1#P#p2#SP#p2sp0.MYI
###        t1#P#p2#SP#p2sp1.MYD
###        t1#P#p2#SP#p2sp1.MYI
###        t1.frm
###        t1.par

DROP TABLE t1;
CREATE TABLE t1 (f_int INTEGER, f_varchar VARCHAR(30))
PARTITION BY RANGE(MOD(f_int,3)) 
SUBPARTITION BY HASH(f_int) SUBPARTITIONS 2
(PARTITION p0 VALUES LESS THAN (1),
 PARTITION p1 VALUES LESS THAN (2),
 PARTITION p2 VALUES LESS THAN (3),
 PARTITION p3 VALUES LESS THAN (4));

ALTER TABLE t1 DROP PARTITION p0;
ALTER TABLE t1 DROP PARTITION p1;
--> ERROR HY000: 
      Error on delete of './test/t1#P#p1#SP#p0sp0.MYI' (Errcode: 2)
ALTER TABLE t1 DROP PARTITION p2;
--> ERROR HY000: Lost connection to MySQL server during query

Results of some additional experiments:
- Table having 3 partitions: 
  3'rd attempt gets the correct response
         1487: Cannot remove all partitions
- Table without subpartitioning: 3'rd attempt gets success (no bug)
- It looks like the crash is caused by BOTH errors which happened before

My environment:
   - Intel PC with Linux(SuSE 9.3)
   - MySQL compiled from source
         Version 5.1 last ChangeSet@1.2299, 2006-04-06

How to repeat:
Please use my attached testscript ml008.test
  copy it to mysql-test/t
  echo "Dummy" > r/ml008.result   # Produce a dummy file with 
                                                   # expected results
  ./mysql-test-run ml008
[10 Apr 2006 15:25] Matthias Leich
testcase

Attachment: ml0008.test (application/test, text), 860 bytes.

[10 Apr 2006 15:26] Matthias Leich
stack trace

Attachment: stacktrace (application/octet-stream, text), 3.82 KiB.

[20 Apr 2006 15:57] Reggie Burnett
Patch approved with emailed comments implemented.
[21 Apr 2006 8:13] Mikael Ronström
Patch will appear in 5.1.10
[23 Apr 2006 3:04] Jon Stephens
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Documented bugfix in 5.1.10 changelog. Closed.