Bug #30878 Partitioning: Crash when alter an auto_increment table to partitioned
Submitted: 6 Sep 2007 20:51 Modified: 16 Nov 2007 12:49
Reporter: Christopher Powers Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Partitions Severity:S1 (Critical)
Version:5.1, 6.0 OS:Any
Assigned to: Mattias Jonsson CPU Architecture:Any
Tags: auto_increment, partitioning

[6 Sep 2007 20:51] Christopher Powers
Description:
The server crashes when trying partition a Falcon table with an auto_increment field.

This is a regression caused by the fix for Bug#27405 "Partitioning InnoDB auto_increment bug".

How to repeat:
This test scenario fails on both Linux and Windows. The server crashes during the alter table command.

--disable_warnings
drop table if exists t1;
--enable_warnings

create table t1 (id int auto_increment, s1 int, primary key (id)) engine=falcon;

insert into t1 values (null,1);
insert into t1 values (null,2);
insert into t1 values (null,3);
insert into t1 values (null,4);
insert into t1 values (null,5);
insert into t1 values (null,6);

select * from t1;

alter table t1 partition by range (id) (partition p1 values less than (3), partition p2 values less than maxvalue);

Suggested fix:
The failure occurs when ha_partition::write_row() tries to lock an uninitialized mutex via pthread_mutex_lock(&table_share->mutex).
[6 Sep 2007 21:10] Miguel Solorzano
Thank you for the bug report. Verified as described.

[New Thread -1267827824 (LWP 4686)]
070906 18:08:06 [Note] Event Scheduler: Loaded 0 events
070906 18:08:06 [Note] /home/miguel/dbs/6.0/libexec/mysqld: ready for connections.
Version: '6.0.3-alpha-debug'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
[New Thread -1268028528 (LWP 4688)]
[New Thread -1325229168 (LWP 4689)]
[New Thread -1335719024 (LWP 4690)]
[New Thread -1356698736 (LWP 4691)]
[New Thread -1369289840 (LWP 4692)]
[New Thread -1379779696 (LWP 4693)]
safe_mutex: Trying to lock unitialized mutex at ha_partition.cc, line 2707

Program received signal SIGABRT, Aborted.
[Switching to Thread -1268028528 (LWP 4688)]
0x00fda402 in __kernel_vsyscall ()
(gdb) bt full
#0  0x00fda402 in __kernel_vsyscall ()
No symbol table info available.
#1  0x00b59d40 in raise () from /lib/libc.so.6
No symbol table info available.
#2  0x00b5b591 in abort () from /lib/libc.so.6
No symbol table info available.
#3  0x087c652f in safe_mutex_lock (mp=0xb16c504, file=0x88fdcf9 "ha_partition.cc", line=2707) at thr_mutex.c:103
        error = 0
#4  0x083e1dd0 in ha_partition::write_row (th
<cut>
[15 Oct 2007 8:31] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/35546

ChangeSet@1.2576, 2007-10-15 10:30:57+02:00, mattiasj@mattiasj-laptop.(none) +3 -0
  Bug #30878: Crashing when alter an auto_increment non partitioned
    table to partitioned
  
  Problem:
  Crashed because usage of an uninitialised mutex when auto_incrementing
    a partitioned temporary table
  
  Fix:
  Only locking (using the mutex) if not temporary table.
[17 Oct 2007 18:33] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/35789

ChangeSet@1.2576, 2007-10-17 20:33:23+02:00, mattiasj@mattiasj-laptop.(none) +3 -0
  Bug #30878: Crashing when alter an auto_increment non partitioned
    table to partitioned
  
  Problem:
  Crashed because usage of an uninitialised mutex when auto_incrementing
    a partitioned temporary table
  
  Fix:
  Only locking (using the mutex) if not temporary table.
[17 Oct 2007 18:40] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/35790

ChangeSet@1.2576, 2007-10-17 20:40:23+02:00, mattiasj@mattiasj-laptop.(none) +3 -0
  Bug #30878: Crashing when alter an auto_increment non partitioned
    table to partitioned
  
  Problem:
  Crashed because usage of an uninitialised mutex when auto_incrementing
    a partitioned temporary table
  
  Fix:
  Only locking (using the mutex) if not temporary table.
[14 Nov 2007 9:41] Bugs System
Pushed into 6.0.4-alpha
[14 Nov 2007 9:45] Bugs System
Pushed into 5.1.23-rc
[15 Nov 2007 13:47] Jon Stephens
Please explain how there could be an issue with Falcon tables in 5.1, since 5.1 doesn't support Falcon.

If this isn't confined to Falcon, then please provide a better description of the issue. Thanks!
[16 Nov 2007 11:13] Mattias Jonsson
Bug not related to falcon, will crash on test case in partition.test (5.1, MyISAM and InnoDB)
[16 Nov 2007 12:49] 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 bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html

Matthias, thanks for the clarification.

Documented bugfix in 5.1.23 and 6.0.4 changelogs as follows:

        Using ALTER TABLE to partition an existing
        non-partitioned table having an AUTO_INCREMENT
        column could crash the server.