Bug #60039 crash when exchanging a partition on nonpartitioned table with a view
Submitted: 9 Feb 2011 9:17 Modified: 10 Mar 2011 11:42
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: Partitions Severity:S1 (Critical)
Version:5.6.2 OS:Any
Assigned to: Mattias Jonsson CPU Architecture:Any

[9 Feb 2011 9:17] Shane Bester
Version: '5.6.2-m5-valgrind-max-debug'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
[New Thread 0x7fffe3f88710 (LWP 22325)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe3f88710 (LWP 22325)]
0x000000000088f71d in Sql_cmd_alter_table_exchange_partition::exchange_partition at ./sql/sql_partition_admin.cc:530
530       table_hton= swap_table->file->ht;
(gdb) bt
#0 in Sql_cmd_alter_table_exchange_partition::exchange_partition at ./sql/sql_partition_admin.cc:530
#1 in Sql_cmd_alter_table_exchange_partition::execute at ./sql/sql_partition_admin.cc:94
#2 in mysql_execute_command at ./sql/sql_parse.cc:4356
#3 in mysql_parse at ./sql/sql_parse.cc:5549
#4 in dispatch_command at ./sql/sql_parse.cc:1078
#5 in do_command at ./sql/sql_parse.cc:815
#6 in do_handle_one_connection at ./sql/sql_connect.cc:748
#7 in handle_one_connection at ./sql/sql_connect.cc:684
#8 in start_thread at pthread_create.c:301
#9 in clone at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115

How to repeat:
#run on mysql-trunk:
drop table if exists `g1`;
create table `g1`(`a` int)engine=innodb;
create or replace view `w1` as select * from `g1`;
alter table `g1` exchange partition `p0` with table `w1`;
[9 Feb 2011 10:37] Valeriy Kravchuk
Verified with current mysql-trunk on 32-bit Ubuntu 10.04:

Version: '5.6.2-m5-valgrind-max-debug'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
110209 12:35:51 - mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 338003 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0xa9ca250
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0xa909f348 thread_stack 0x30000

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0xaa1ecd0): alter table `g1` exchange partition `p0` with table `w1`
Connection ID (thread ID): 1
[9 Feb 2011 11:44] Mattias Jonsson
Assigning myself, since I wrote WL#4445/EXCHANGE PARTITION.
[10 Feb 2011 9:51] 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:


3624 Mattias Jonsson	2011-02-10
      Bug#60039: crash when exchanging a partition on
                 nonpartitioned table with a view
      Since the table was a view, it was never opened.
      Due to this it crashed on null pointer reference.
      Fixed by checking the tables before using it.
     @ mysql-test/r/partition_error.result
        updated result
     @ mysql-test/t/partition_error.test
        added test
     @ sql/sql_partition_admin.cc
        check swap_table before using it.
[10 Mar 2011 11:42] Jon Stephens
Fixed in 5.6.3. Since the issue did not occur in a release version, no changelog entry is required. Closed.
[10 Mar 2011 12:07] Jon Stephens
MJ informs me that the issue does exist in 5.6.2.

Documented fix in the 5.6.3 changelog as follows:

        Attempting to use ALTER TABLE ... EXCHANGE PARTITION to exchange
        a view with a (nonexistent) partition of a table that was not
        partitioned caused the server to crash.

No status change.