Bug #56702 Update on Federated and non-federated table results in mysql restart
Submitted: 9 Sep 2010 18:52 Modified: 20 Feb 2012 13:52
Reporter: Tyson Lowery Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Federated storage engine Severity:S1 (Critical)
Version:5.1.50, 5.5.11 OS:Any
Assigned to: CPU Architecture:Any
Tags: federated

[9 Sep 2010 18:52] Tyson Lowery
Description:
My Database has 2 tables. One of them is InnoDB, the other is a Federated table that is linked to an InnoDB table in another database on the same server. 

If I run an update like this, MySQL actually restarts! 

update fedtable, innotable set fedtable.field = 1 where fedtable.ID = innotable.ID and innotable.Field = "XYZ" 

Have I set something up wrong, or is this a bug?  I've tried different combinations of InnoDB and MyISAM tables and the result seems to be the same each time.

How to repeat:
My Database has 2 tables. One of them is InnoDB, the other is a Federated table that is linked to an InnoDB table in another database on the same server. 

update fedtable, innotable set fedtable.field = 1 where fedtable.ID = innotable.ID and innotable.Field = "XYZ" 

Suggested fix:
Make it so this works.
[9 Sep 2010 19:09] Tyson Lowery
This is the table that is federated to the other database:

CREATE TABLE `teamplayer` (
  `tp_id` int(10) NOT NULL AUTO_INCREMENT,
  `tp_team_id` int(5) NOT NULL DEFAULT '0',
  `tp_name` varchar(30) NOT NULL DEFAULT '',
  `tp_isMajor` int(1) NOT NULL DEFAULT '1',
  `tp_dob` date NOT NULL DEFAULT '0000-00-00',
  `tp_player_bats` char(1) NOT NULL DEFAULT '',
  `tp_player_throws` char(1) NOT NULL DEFAULT '',
  `tp_player_arm` tinyint(3) NOT NULL DEFAULT '0',
  `tp_player_range` tinyint(3) NOT NULL DEFAULT '0',
  `tp_player_speed` tinyint(3) NOT NULL DEFAULT '0',
  `tp_player_contact_vs_lefty` tinyint(3) NOT NULL DEFAULT '0',
  `tp_player_contact_vs_righty` tinyint(3) NOT NULL DEFAULT '0',
  `tp_player_power_vs_lefty` tinyint(3) NOT NULL DEFAULT '0',
  `tp_player_power_vs_righty` tinyint(3) NOT NULL DEFAULT '0',
  `tp_player_bunt` tinyint(3) NOT NULL DEFAULT '0',
  `tp_player_velocity` tinyint(3) NOT NULL DEFAULT '0',
  `tp_player_control` tinyint(3) NOT NULL DEFAULT '0',
  `tp_player_endurance` tinyint(3) NOT NULL DEFAULT '0',
  `tp_player_pos` tinyint(2) NOT NULL DEFAULT '0',
  `tp_lineup_lefty_pos` tinyint(2) NOT NULL DEFAULT '0',
  `tp_lineup_righty_pos` tinyint(2) NOT NULL DEFAULT '0',
  `tp_lineup_lefty` tinyint(2) NOT NULL DEFAULT '0',
  `tp_lineup_righty` tinyint(2) NOT NULL DEFAULT '0',
  `tp_lineup_pitching` tinyint(2) NOT NULL DEFAULT '0',
  `tp_dayssincelastpitched` int(3) NOT NULL DEFAULT '0',
  `tp_inningslastpitched` tinyint(2) NOT NULL DEFAULT '0',
  `tp_player_health` tinyint(3) NOT NULL DEFAULT '0',
  `tp_injuredgames` tinyint(3) NOT NULL DEFAULT '0',
  `tp_dlreturndate` date NOT NULL DEFAULT '1949-01-01',
  `tp_draft_year` int(4) NOT NULL DEFAULT '1950',
  `tp_drafted` int(4) DEFAULT NULL,
  `tp_draftpos` tinyint(2) NOT NULL DEFAULT '0',
  `tp_draftedbyteam_id` int(5) NOT NULL DEFAULT '0',
  `tp_expdrafted` smallint(4) NOT NULL DEFAULT '0',
  `tp_coach_points` tinyint(3) NOT NULL DEFAULT '0',
  `tp_league_id` smallint(6) NOT NULL DEFAULT '0',
  `tp_consecutive` int(20) NOT NULL DEFAULT '0',
  `tp_pos2_pos` int(2) NOT NULL DEFAULT '0',
  `tp_pos2_rating` int(10) NOT NULL DEFAULT '0',
  `tp_pos3_pos` int(2) NOT NULL DEFAULT '0',
  `tp_pos3_rating` int(10) NOT NULL DEFAULT '0',
  `tp_pos4_pos` int(2) NOT NULL DEFAULT '0',
  `tp_pos4_rating` int(10) NOT NULL DEFAULT '0',
  `tp_pos5_pos` tinyint(2) NOT NULL DEFAULT '0',
  `tp_pos5_rating` int(4) NOT NULL DEFAULT '0',
  `tp_pos6_pos` tinyint(2) NOT NULL DEFAULT '0',
  `tp_pos6_rating` int(4) NOT NULL DEFAULT '0',
  `tp_pos7_pos` tinyint(2) NOT NULL DEFAULT '0',
  `tp_pos7_rating` int(4) NOT NULL DEFAULT '0',
  `tp_pos8_pos` tinyint(2) NOT NULL DEFAULT '0',
  `tp_pos8_rating` int(4) NOT NULL DEFAULT '0',
  `tp_pos9_pos` tinyint(2) NOT NULL DEFAULT '0',
  `tp_pos9_rating` int(4) NOT NULL DEFAULT '0',
  `tp_coach_pos` int(4) NOT NULL DEFAULT '0',
  `tp_lastskillupdate_year` int(10) NOT NULL DEFAULT '0',
  `tp_battersfaced1` int(4) NOT NULL DEFAULT '0',
  `tp_battersfaced2` int(4) NOT NULL DEFAULT '0',
  `tp_battersfaced3` int(4) NOT NULL DEFAULT '0',
  `tp_battersfaced4` int(4) NOT NULL DEFAULT '0',
  `tp_battersfaced5` int(4) NOT NULL DEFAULT '0',
  `tp_service` int(6) NOT NULL DEFAULT '0',
  `tp_waiverreclaims` tinyint(2) NOT NULL DEFAULT '0',
  `tp_resting` tinyint(2) NOT NULL DEFAULT '0',
  `tp_playoffapps` tinyint(4) NOT NULL DEFAULT '0',
  `tp_wsapps` tinyint(4) NOT NULL DEFAULT '0',
  `tp_wswins` tinyint(4) NOT NULL DEFAULT '0',
  `tp_leadership` tinyint(3) NOT NULL DEFAULT '0',
  `tp_mentoring` smallint(3) NOT NULL DEFAULT '0',
  `tp_poineligible` char(1) NOT NULL DEFAULT '0',
  `tp_hof` tinyint(1) NOT NULL DEFAULT '0',
  `tp_salary` decimal(5,2) NOT NULL DEFAULT '0.00',
  `tp_lastcontractyear` smallint(4) NOT NULL DEFAULT '1949',
  `tp_contracttype` tinyint(1) NOT NULL DEFAULT '0',
  `tp_dt_id` smallint(5) NOT NULL DEFAULT '1',
  `tp_face` int(11) NOT NULL DEFAULT '0',
  `tp_alltimeleader` tinyint(1) NOT NULL DEFAULT '0',
  `tp_onblock` tinyint(4) NOT NULL DEFAULT '0',
  `tp_onblocknotes` varchar(255) DEFAULT NULL,
  `tp_onblockdate` date NOT NULL DEFAULT '2010-01-01',
  PRIMARY KEY (`tp_id`),
  KEY `tp_team_id` (`tp_team_id`),
  KEY `tp_league_id` (`tp_league_id`),
  KEY `tp_dt_id` (`tp_dt_id`)
) ENGINE=MyISAM AUTO_INCREMENT=62061 DEFAULT CHARSET=latin1 |

This is the other table:
CREATE TABLE `waiver` (
  `waiver_id` int(10) NOT NULL AUTO_INCREMENT,
  `waiver_tp_id` int(10) NOT NULL DEFAULT '0',
  `waiver_dateoff` date NOT NULL DEFAULT '0000-00-00',
  `waiver_type` tinyint(2) NOT NULL DEFAULT '1',
  `waiver_active` tinyint(2) NOT NULL DEFAULT '1',
  `waiver_oldteam_id` int(10) NOT NULL DEFAULT '0',
  `waiver_lastteam_id` int(10) NOT NULL,
  PRIMARY KEY (`waiver_id`),
  KEY `waiver_tp_id` (`waiver_tp_id`),
  KEY `waiver_lastteam_id` (`waiver_lastteam_id`)
) ENGINE=InnoDB AUTO_INCREMENT=339901 DEFAULT CHARSET=latin1 

This is the query that causes the reboot:

update teamplayer, waiver set  tp_resting = 0, tp_isMajor = 1, tp_lineup_lefty = 0, tp_lineup_righty = 0, tp_lineup_lefty_pos = 0, tp_lineup_righty_pos = 0, tp_lineup_pitching = 0, tp_coach_pos = 0, tp_coach_points = 0, waiver_active = 0, tp_team_id = 36483, tp_onblock = 0, tp_onblocknotes = '', tp_onblockdate = '2010-01-01' where tp_id = waiver_tp_id and waiver_id = 145;
[17 Jul 2011 12:25] Valeriy Kravchuk
Please, check if the same problem still happens with a recent version, 5.1.58. If it does, please, send the entire error log of MySQL server.
[17 Aug 2011 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[18 Sep 2011 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[19 Jan 2012 7:15] Cheng Huang
This bug exists on version 5.5.11.
I have two tables in the database: TableA (myisam) and TableB (federated, connected to another myisam table).

column CO is primary key for both.

If execute sql:
UPDATE TableB, TableA SET TableB.1221_C1 = TableA.C1, TableB.1221_C2 = TableA.C2 WHERE TableB.CO = TableA.CO;

mysqld crashed and then restart.

In localhost.localdomain.err :

120119 14:49:12 [Note] Recovering after a crash using mysql-bin
120119 14:49:12 [Note] Starting crash recovery...
120119 14:49:12 [Note] Crash recovery finished.
120119 14:49:12 [Note] Event Scheduler: Loaded 2 events
120119 14:49:12 [Note] Event Scheduler: scheduler thread started with id 1
120119 14:49:12 [Note] /opt/mysql5.5/bin/mysqld: ready for connections.
Version: '5.5.11-log'  socket: '/opt/mysql5.5/data/mysql.sock'  port: 3306  Source distribution
120119 14:49:13 [Warning] IP address '10.7.3.206' could not be resolved: no reverse address mapping.
120119 14:49:16 [Warning] IP address '10.10.21.116' could not be resolved: no reverse address mapping.
120119 14:49:16 [Warning] IP address '10.10.21.41' could not be resolved: no reverse address mapping.
120119 14:50:10 [Warning] IP address '10.7.3.166' could not be resolved: no reverse address mapping.
120119 14:50:10 [Note] Start binlog_dump to slave_server(166), pos(mysql-bin.000156, 1387)
[19 Jan 2012 7:38] Cheng Huang
I did another test on this bug.

Details:

On linux, "uname -a" shows 
"Linux localhost.localdomain 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux"

mysql version : Server version: 5.5.11-log Source distribution

step1: create two schemas:

CREATE DATABASE `hctest3`;
CREATE DATABASE `hctest4`;

step2: create three tables: 2 myisam tables and 1 federated table.

CREATE TABLE  `hctest3`.`TableA` (
  `CO` int(10) unsigned NOT NULL,
  `C1` int(10) unsigned NOT NULL,
  `C2` int(10) unsigned NOT NULL,
  PRIMARY KEY (`CO`)
) ENGINE=MyISAM DEFAULT CHARSET=gbk;

CREATE TABLE  `hctest4`.`TableB` (
  `CO` int(10) unsigned NOT NULL,
  `C1` int(10) unsigned NOT NULL,
  `C2` int(10) unsigned NOT NULL,
  PRIMARY KEY (`CO`)
) ENGINE=MyISAM DEFAULT CHARSET=gbk;

CREATE TABLE  `hctest3`.`TableB` (
  `CO` int(10) unsigned NOT NULL,
  `C1` int(10) unsigned NOT NULL,
  `C2` int(10) unsigned NOT NULL,
  PRIMARY KEY (`CO`)
) ENGINE=FEDERATED DEFAULT CHARSET=gbk CONNECTION='mysql://user:passwd@ip:port/hctest4/TableB';

step3: Insert init data
USE hctest3;
INSERT INTO TableA VALUES (1,1,1);
INSERT INTO TableB VALUES (1,2,2);

step4: try to update federated table (hctest3.TableB ) with data in myisam table (hctest3.TableA)

UPDATE TableB, TableA SET TableB.C1 = TableA.C1, TableB.C2 = TableA.C2 WHERE TableB.CO = TableA.CO;

Then mysql crashed and I got msg "Lost connection to MySQL server during query".

Log in localhost.localdomain.err :

120119 15:25:03 - 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.

key_buffer_size=16777216
read_buffer_size=2147479552
max_used_connections=9
max_threads=30
thread_count=10
connection_count=9
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 62946524 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x26033930
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 = 0x4177c0d0 thread_stack 0x40000
/opt/mysql5.5/bin/mysqld(my_print_stacktrace+0x33)[0x7637e3]
/opt/mysql5.5/bin/mysqld(handle_segfault+0x36e)[0x4ef04e]
/lib64/libpthread.so.0[0x303260e7c0]
/opt/mysql5.5/lib/plugin/ha_federated.so(_ZN12ha_federated7rnd_posEPhS0_+0x3f)[0x2aaaabd9d71f]
/opt/mysql5.5/bin/mysqld(_ZN12multi_update10do_updatesEv+0x3aa)[0x5c108a]
/opt/mysql5.5/bin/mysqld(_ZN12multi_update8send_eofEv+0x268)[0x5c14c8]
/opt/mysql5.5/bin/mysqld[0x58965e]
/opt/mysql5.5/bin/mysqld(_ZN4JOIN4execEv+0x1210)[0x5926c0]
/opt/mysql5.5/bin/mysqld(_Z12mysql_selectP3THDPPP4ItemP10TABLE_LISTjR4ListIS1_ES2_jP8st_orderSB_S2_SB_yP13select_resultP18st_select_lex_unitP13st_select_lex+0x1c0)[0x5939a0]
/opt/mysql5.5/bin/mysqld(_Z18mysql_multi_updateP3THDP10TABLE_LISTP4ListI4ItemES6_PS4_y15enum_duplicatesbP18st_select_lex_unitP13st_select_lexPP12multi_update+0x13c)[0x5bf88c]
/opt/mysql5.5/bin/mysqld(_Z21mysql_execute_commandP3THD+0xd0b)[0x559e4b]
/opt/mysql5.5/bin/mysqld(_Z11mysql_parseP3THDPcjP12Parser_state+0xfe)[0x55ee9e]
/opt/mysql5.5/bin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0x1353)[0x560253]
/opt/mysql5.5/bin/mysqld(_Z10do_commandP3THD+0xc2)[0x560582]
/opt/mysql5.5/bin/mysqld(_Z24do_handle_one_connectionP3THD+0x2f1)[0x5ea771]
/opt/mysql5.5/bin/mysqld(handle_one_connection+0x4a)[0x5ea85a]
/lib64/libpthread.so.0[0x30326064a7]
/lib64/libc.so.6(clone+0x6d)[0x3031ad3c2d]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x2603a6e0): UPDATE TableB, TableA SET TableB.C1 = TableA.C1, TableB.C2 = TableA.C2 WHERE TableB.CO = TableA.CO
Connection ID (thread ID): 25
Status: NOT_KILLED

The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
120119 15:25:03 mysqld_safe Number of processes running now: 0
120119 15:25:03 mysqld_safe mysqld restarted
120119 15:25:03 [Warning] option 'read_buffer_size': unsigned value 2147483648 adjusted to 2147479552
120119 15:25:03 [Warning] option 'read_rnd_buffer_size': unsigned value 8589934592 adjusted to 2147483647
120119 15:25:03 InnoDB: The InnoDB memory heap is disabled
120119 15:25:03 InnoDB: Mutexes and rw_locks use GCC atomic builtins
120119 15:25:03 InnoDB: Compressed tables use zlib 1.2.3
120119 15:25:03 InnoDB: Initializing buffer pool, size = 3.4G
120119 15:25:03 InnoDB: Completed initialization of buffer pool
120119 15:25:04 InnoDB: highest supported file format is Barracuda.
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
120119 15:25:04  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Last MySQL binlog file position 0 2328, file name ./mysql-bin.000132
120119 15:25:04  InnoDB: Waiting for the background threads to start
120119 15:25:05 InnoDB: 1.1.6 started; log sequence number 12658597256
120119 15:25:05 [Note] Recovering after a crash using mysql-bin
120119 15:25:05 [Note] Starting crash recovery...
120119 15:25:05 [Note] Crash recovery finished.
120119 15:25:05 [Note] Event Scheduler: Loaded 2 events
120119 15:25:05 [Note] Event Scheduler: scheduler thread started with id 1
120119 15:25:05 [Note] /opt/mysql5.5/bin/mysqld: ready for connections.
Version: '5.5.11-log'  socket: '/opt/mysql5.5/data/mysql.sock'  port: 3306  Source distribution
120119 15:25:05 [Warning] IP address '10.10.21.41' could not be resolved: no reverse address mapping.
120119 15:25:06 [Warning] IP address '10.7.3.206' could not be resolved: no reverse address mapping.
120119 15:25:06 [Warning] IP address '10.10.21.116' could not be resolved: no reverse address mapping.
[20 Jan 2012 13:52] Valeriy Kravchuk
5.5.11 is still very old and many bugs were fixed since that. We need a repeatable test case for 5.1.61 or 5.5.20 to proceed.
[21 Feb 2012 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".