Bug #32067 Partitions: crash with timestamp column
Submitted: 2 Nov 2007 23:13 Modified: 16 Nov 2007 12:57
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Partitions Severity:S3 (Non-critical)
Version:5.1.23-rc-debug OS:Linux (SUSE 10 64-bit)
Assigned to: Alexey Botchkov CPU Architecture:Any

[2 Nov 2007 23:13] Peter Gulutzan
Description:
I create an InnoDB table partitioned with a TIMESTAMP column.
I create a procedure which causes the TIMESTAMP column to change
repeatedly due to an ON UPDATE CURRENT_TIMESTAMP clause.
I run the procedure.
After a while, usually after several hundred updates, crash.

How to repeat:
delimiter ;
drop table if exists t9;
drop procedure p;
create table t9
 (s1 timestamp on update current_timestamp, s2 binary(5))
 engine=innodb partition by key(s1) partitions 10;
create unique index i on t9 (s1);
insert into t9 values (null,null);
delimiter //
create procedure p ()
begin
  declare v int default 0;
  while v < 1000000 do
    select v;
    update t9 set s2 = char(v%100);
    commit;
  set v = v + 1;
  end while;
  end//
delimiter ;
call p();
[3 Nov 2007 7:45] MySQL Verification Team
Thank you for the bug report. Verified as described.

 	mysqld.exe!row_update_for_mysql()  + 0x1a6 bytes	C
 	mysqld.exe!ha_innobase::update_row()  + 0x14c bytes	C++
>	mysqld.exe!ha_partition::update_row(const unsigned char * old_data=0x000000000300fa60, unsigned char * new_data=0x000000000300fd88)  Line 2824	C++
 	mysqld.exe!handler::ha_update_row(const unsigned char * old_data=0x0000000002fa67a0, unsigned char * new_data=0xfffffffffffffffe)  Line 3676 + 0x12 bytes	C++
 	mysqld.exe!mysql_update(THD * thd=0x0000000000000000, TABLE_LIST * table_list=0x0000000002fa67a0, List<Item> & fields={...}, List<Item> & values={...}, Item * conds=0x0000000000000000, unsigned int order_num=0, st_order * order=0x0000000000000000, unsigned __int64 limit=18446744073709551615, enum_duplicates handle_duplicates=DUP_ERROR, int ignore=0)  Line 635 + 0x11 bytes	C++
 	mysqld.exe!mysql_execute_command(THD * thd=0x000000000000001e)  Line 2629 + 0x63 bytes	C++
 	mysqld.exe!sp_instr_stmt::exec_core(THD * thd=0x0000000000000000, unsigned int * nextp=0x0000000000000000)  Line 2765	C++
 	mysqld.exe!sp_lex_keeper::reset_lex_and_exec_core(THD * thd=0x000000000502dcd0, unsigned int * nextp=0x0000000003028630, int open_tables=49964960, sp_instr * instr=0x0000000003028630)  Line 2606 + 0x11 bytes	C++
 	mysqld.exe!sp_instr_stmt::execute(THD * thd=0x0000000000000000, unsigned int * nextp=0x0000000003028630)  Line 2716	C++
 	mysqld.exe!sp_head::execute(THD * thd=0x0000000002fa67a0)  Line 1167 + 0x11 bytes	C++
 	mysqld.exe!sp_head::execute_procedure(THD * thd=0x0000000003026fc0, List<Item> * args=0x0000000000000000)  Line 1876 + 0xb bytes	C++
 	mysqld.exe!mysql_execute_command(THD * thd=0x0000000002fa67a0)  Line 3890 + 0x12 bytes	C++
 	mysqld.exe!mysql_parse(THD * thd=0x0000000002ff5b61, const char * inBuf=0x0000000000000003, unsigned int length=49964960, const char * * found_semicolon=0x0000000000000000)  Line 5463	C++
 	mysqld.exe!dispatch_command(enum_server_command command=COM_SLEEP, THD * thd=0x000000000000ea60, char * packet=0x0000000002fa71e8, unsigned int packet_length=0)  Line 960	C++
 	mysqld.exe!do_command(THD * thd=0x0000000002fa67a0)  Line 717 + 0x11 bytes	C++
 	mysqld.exe!handle_one_connection(void * arg=0x0000000002fa67a0)  Line 1099 + 0xa bytes	C++
 	mysqld.exe!pthread_start()  + 0x55 bytes	C
 	mysqld.exe!_callthreadstart()  Line 295	C
 	mysqld.exe!_threadstart(void * ptd=0x0000000000000000)  Line 275 + 0x5 bytes	C
 	kernel32.dll!0000000076eccdcd() 	
 	[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]	
 	ntdll.dll!00000000770ec6e1()
[12 Nov 2007 17:16] 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/37592

ChangeSet@1.2625, 2007-11-12 21:11:31+04:00, holyfoot@mysql.com +3 -0
  Bug #32067 Partitions: crash with timestamp column.
  
  Partition handler fails updating tables with partitioning
  based on timestamp field, as it calculates the timestamp field
  AFTER it calculates the number of partition of a record.
  
  Fixed by adding timestamp_field->set_time() call and disabling
  such consequent calls
[16 Nov 2007 9:32] Bugs System
Pushed into 5.1.23-rc
[16 Nov 2007 9:35] Bugs System
Pushed into 6.0.4-alpha
[16 Nov 2007 12:57] 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

Documented as follows in 5.1.23 and 6.0.4 changelogs:

        Repeated inserts into a table partitioned by
        KEY on a TIMESTAMP column
        led to a crash of the server.