Bug #42419 | Server crash with "Pure virtual method called" on two concurrent connections | ||
---|---|---|---|
Submitted: | 28 Jan 2009 13:15 | Modified: | 18 Mar 2009 14:57 |
Reporter: | Elena Stepanova | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server | Severity: | S1 (Critical) |
Version: | 4.1.24, 5.0.42, 5.0.74, 5.0.76, 5.0.77, 5.1.31 | OS: | Any |
Assigned to: | Georgi Kodinov | CPU Architecture: | Any |
Tags: | crash, subquery, UPDATE |
[28 Jan 2009 13:15]
Elena Stepanova
[28 Jan 2009 13:18]
Elena Stepanova
pstack core (c++filt)
Attachment: pstack_core_1 (application/octet-stream, text), 98.77 KiB.
[28 Jan 2009 15:34]
Valeriy Kravchuk
Thank you for a problem report. Had you identified specific query that leads to this problem? Any ideas on how to reapeat are greatly appriciated.
[28 Jan 2009 19:43]
Elena Stepanova
As I wrote in the description, it is a stress test with many connections running different scenarios on the same tables concurrently in a rapid fashion, so due to race conditions they can produce a huge number of possible execution branches. I'll keep trying to track down the exact action which causes the problem, but it might be much faster to have a developer take a look at core files (I can offer wide choice of those) -- if they don't figure the error itself, they might give a hint on which queries/actions could be most suspicious and worth paying attention to, for example to point that a function in question might be called only upon queries of a certain type, etc.
[3 Feb 2009 2:14]
Elena Stepanova
Scenario to reproduce (2 client connections needed): # CONNECTION 1 CREATE DATABASE systest1; USE systest1; CREATE TABLE tb1_eng1 ( i1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (i1), f1 INT ) ENGINE = InnoDB; INSERT INTO systest1.tb1_eng1 VALUES (1,1),(2,2),(3,3); COMMIT; SET AUTOCOMMIT = 0; CREATE TEMPORARY TABLE systest1.t1_tmp ( f1 INT ); INSERT INTO systest1.t1_tmp (f1) SELECT f1 FROM systest1.tb1_eng1 WHERE i1 = 3; INSERT INTO systest1.t1_tmp (f1) SELECT f1 FROM systest1.tb1_eng1 WHERE i1 = 2; # CONNECTION 2 SET AUTOCOMMIT = 0; USE systest1; CREATE TEMPORARY TABLE systest1.t2_tmp ( i1 int, new_i1 int ); INSERT INTO systest1.t2_tmp VALUES (1,51),(2,52),(3,53); UPDATE systest1.tb1_eng1 target SET i1 = (SELECT new_i1 FROM systest1.t2_tmp source WHERE source.i1 = target.i1) WHERE i1 = 1; UPDATE systest1.tb1_eng1 target SET i1 = (SELECT new_i1 FROM systest1.t2_tmp source WHERE source.i1 = target.i1) WHERE i1 = 2; # While connection 2 is waiting for lock, ... # CONNECTION 1 INSERT INTO systest1.t1_tmp (f1) SELECT f1 FROM systest1.tb1_eng1 WHERE i1 = 1; # Connection 1 says # ERROR 1213 (40001): Deadlock found when trying to get lock; try restarting transaction # Connection 2 gets lock and finishes query # CONNECTION 2 UPDATE systest1.tb1_eng1 target SET i1 = (SELECT new_i1 FROM systest1.t2_tmp source WHERE source.i1 = target.i1) WHERE i1 = 3; ################## At this moment mysqld dies with error message and core file as described before. The problem is also reproducible in 5.0.67, 5.0.72sp1, 5.1.30.
[3 Feb 2009 2:20]
Elena Stepanova
Core file and pstack were from Solaris Sparc, but the problem is reproducible on Linux as well. Also, in the scenario above missed the leading query on connection #1: DROP DATABASE IF EXISTS systest1; # the rest as described
[3 Feb 2009 6:07]
MySQL Verification Team
I repeated this on 5.0.74 and 5.1.30 on windows too.
[3 Feb 2009 7:03]
MySQL Verification Team
testcase
Attachment: bug42419.c (text/plain), 7.71 KiB.
[13 Feb 2009 15:32]
Georgi Kodinov
Just for the record : with a fresh 5.0-bk Shane's test program doesn't seem to reproduce it. I'm getting a lot of : query failed 'update tb1_eng1 target set i1 = (select new_i1 from t2_tmp source where source.i1 = target.i1) where i1 = abs(4)%10' : 1242 (Subquery returns more than 1 row) (21000) and some (at the beginning): select f1 from tb1_eng1 where i1 = abs(14)%10' : 1146 (Table 'test.t1_tmp' doesn't exist) (42S02) Looking further.
[13 Feb 2009 15:59]
Georgi Kodinov
bug42419.test : mysqltest script to reproduce the crash
Attachment: bug42419.test (, text), 1.34 KiB.
[17 Feb 2009 10:58]
Georgi Kodinov
a 5.0-bugteam callstack: #0 0x000000312300c216 in pthread_kill () from /lib64/libpthread.so.0 #1 0x00000000007b808e in write_core (sig=11) at stacktrace.c:254 #2 0x000000000061be59 in handle_segfault (sig=11) at mysqld.cc:2376 #3 <signal handler called> #4 0x00000000006851e0 in part_of_refkey (table=0x30218c8, field=0x30225f8) at sql_select.cc:12121 #5 0x00000000006852d8 in test_if_ref (left_item=0x3030188, right_item=0x3030090) at sql_select.cc:11986 #6 0x000000000068a396 in make_cond_for_table (cond=0x3030270, tables=13835058055282163713, used_table=13835058055282163713) at sql_select.cc:12100 #7 0x0000000000699a58 in make_join_select (join=0x301f8d8, select=0x3020e98, cond=0x3030270) at sql_select.cc:5805 #8 0x00000000006a7fe1 in JOIN::optimize (this=0x301f8d8) at sql_select.cc:999 #9 0x00000000005da84e in subselect_single_select_engine::exec (this=0x30304d8) at item_subselect.cc:1798 #10 0x00000000005d86bc in Item_subselect::exec (this=0x30303e0) at item_subselect.cc:212 #11 0x00000000005d93b5 in Item_singlerow_subselect::val_int (this=0x30303e0) at item_subselect.cc:506 #12 0x000000000056b69a in Item::save_in_field (this=0x30303e0, field=0x30225f8, no_conversions=false) at item.cc:4737 #13 0x000000000066e4dc in fill_record (thd=0x3024e98, fields=@0x30267e0, values=@0x3026b48, ignore_errors=false) at sql_base.cc:5815 #14 0x000000000066e5e8 in fill_record_n_invoke_before_triggers (thd=0x3024e98, fields=@0x30267e0, values=@0x3026b48, ignore_errors=false, triggers=0x0, event=TRG_EVENT_UPDATE) at sql_base.cc:5860 #15 0x00000000006cac27 in mysql_update (thd=0x3024e98, table_list=0x302f218, fields=@0x30267e0, values=@0x3026b48, conds=0x30306a8, order_num=0, order=0x0, limit=18446744073709551615, handle_duplicates=DUP_ERROR, ignore=false) at sql_update.cc:465 #16 0x0000000000639ea0 in mysql_execute_command (thd=0x3024e98) at sql_parse.cc:3590 #17 0x000000000063fc32 in mysql_parse (thd=0x3024e98, inBuf=0x302f0c8 "UPDATE systest1.tb1_eng1 target\nSET i1 = (SELECT new_i1 FROM systest1.t2_tmp source WHERE source.i1 = target.i1)\nWHERE i1 = 3", length=125, found_semicolon=0x7fc7ff6e1e40) at sql_parse.cc:6267 #18 0x0000000000640951 in dispatch_command (command=COM_QUERY, thd=0x3024e98, packet=0x3027039 "UPDATE systest1.tb1_eng1 target\nSET i1 = (SELECT new_i1 FROM systest1.t2_tmp source WHERE source.i1 = target.i1)\nWHERE i1 = 3", packet_length=126) at sql_parse.cc:1938 #19 0x0000000000642089 in do_command (thd=0x3024e98) at sql_parse.cc:1628 #20 0x0000000000642595 in handle_one_connection (arg=0x3024e98) at sql_parse.cc:1234 #21 0x00000031230073da in start_thread () from /lib64/libpthread.so.0 #22 0x00000031224e62bd in clone () from /lib64/libc.so.6
[17 Feb 2009 18:11]
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/66698 2742 Georgi Kodinov 2009-02-17 Bug #42419: Server crash with "Pure virtual method called" on two concurrent connections The problem is that tables can enter open table cache for a thread without being properly cleaned up. This can happen if make_join_statistics() fails to read a const table because of e.g. a deadlock. It does set a member of TABLE structure to a value it allocates, but doesn't clean-up this setting on error nor does it set the rest of the members in JOIN to allow for automatic cleanup. As a result when such an error occurs and the next statement depends re-uses the table from the open tables cache it will get it with this TABLE::reginfo.join_tab pointing to a memory area that's freed. Fixed by making sure make_join_statistics() cleans up TABLE::reginfo.join_tab on error. modified: mysql-test/r/innodb_mysql.result mysql-test/t/innodb_mysql.test sql/sql_select.cc
[19 Feb 2009 14:55]
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/66925 2742 Georgi Kodinov 2009-02-19 Bug #42419: Server crash with "Pure virtual method called" on two concurrent connections The problem is that tables can enter open table cache for a thread without being properly cleaned up. This can happen if make_join_statistics() fails to read a const table because of e.g. a deadlock. It does set a member of TABLE structure to a value it allocates, but doesn't clean-up this setting on error nor does it set the rest of the members in JOIN to allow for automatic cleanup. As a result when such an error occurs and the next statement depends re-uses the table from the open tables cache it will get it with this TABLE::reginfo.join_tab pointing to a memory area that's freed. Fixed by making sure make_join_statistics() cleans up TABLE::reginfo.join_tab on error. @ mysql-test/r/innodb_mysql.result Bug #42419: test case @ mysql-test/t/innodb_mysql.test Bug #42419: test case @ sql/sql_select.cc Bug #42419: clean up the members of TABLE on failure in make_join_statisitcs()
[19 Feb 2009 15: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/66933 2742 Georgi Kodinov 2009-02-19 Bug #42419: Server crash with "Pure virtual method called" on two concurrent connections The problem is that tables can enter open table cache for a thread without being properly cleaned up. This can happen if make_join_statistics() fails to read a const table because of e.g. a deadlock. It does set a member of TABLE structure to a value it allocates, but doesn't clean-up this setting on error nor does it set the rest of the members in JOIN to allow for automatic cleanup. As a result when such an error occurs and the next statement depends re-uses the table from the open tables cache it will get it with this TABLE::reginfo.join_tab pointing to a memory area that's freed. Fixed by making sure make_join_statistics() cleans up TABLE::reginfo.join_tab on error. @ mysql-test/r/innodb_mysql.result Bug #42419: test case @ mysql-test/t/innodb_mysql-master.opt Bug #42419: increase the timeout so it covers te conservative sleep 3 in the test @ mysql-test/t/innodb_mysql.test Bug #42419: test case @ sql/sql_select.cc Bug #42419: clean up the members of TABLE on failure in make_join_statisitcs()
[20 Feb 2009 9:13]
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/66999 2755 Georgi Kodinov 2009-02-20 Bug #42419: test suite fix Moved the test case for the bug into a separate file (and restored the original innodb_mysql test setup). Used the new wait_show_condition test macro to avoid the usage of sleep @ mysql-test/include/wait_show_condition.inc Bug #42419: new test macro to wait for a row in SHOW to have a certain value. @ mysql-test/r/innodb_bug42419.result Bug #42419: test case @ mysql-test/r/innodb_mysql.result Bug #42419: revert to the original innodb_mysql test @ mysql-test/t/innodb_bug42419.test Bug #42419: test case @ mysql-test/t/innodb_mysql-master.opt Bug #42419: revert to the original innodb_mysql test @ mysql-test/t/innodb_mysql.test Bug #42419: revert to the original innodb_mysql test
[9 Mar 2009 14:13]
Bugs System
Pushed into 5.0.79 (revid:joro@sun.com-20090309135922-a0di9ebkxoj4d4wv) (version source revid:joro@sun.com-20090220091206-nj6djcj323w1pbae) (merge vers: 5.0.79) (pib:6)
[11 Mar 2009 1:53]
Paul DuBois
Noted in 5.0.79 changelog. Tables could enter open table cache for a thread without being properly cleaned up, leading to a server crash. Setting report to NDI pending push into 5.1.x/6.0.x.
[13 Mar 2009 19:06]
Bugs System
Pushed into 5.1.33 (revid:joro@sun.com-20090313111355-7bsi1hgkvrg8pdds) (version source revid:azundris@mysql.com-20090224070618-mr7stu6rfcvoj18g) (merge vers: 5.1.33) (pib:6)
[14 Mar 2009 1:43]
Paul DuBois
Noted in 5.1.33 changelog. Setting report to NDI pending push into 6.0.x.
[18 Mar 2009 13:19]
Bugs System
Pushed into 6.0.11-alpha (revid:joro@sun.com-20090318122208-1b5kvg6zeb4hxwp9) (version source revid:azundris@mysql.com-20090223123708-n9rf2to3g15br7za) (merge vers: 6.0.10-alpha) (pib:6)
[18 Mar 2009 14:57]
Paul DuBois
Noted in 6.0.11 changelog.
[9 May 2009 16:45]
Bugs System
Pushed into 5.1.34-ndb-6.2.18 (revid:jonas@mysql.com-20090508185236-p9b3as7qyauybefl) (version source revid:jonas@mysql.com-20090508100057-30ote4xggi4nq14v) (merge vers: 5.1.33-ndb-6.2.18) (pib:6)
[9 May 2009 17:41]
Bugs System
Pushed into 5.1.34-ndb-6.3.25 (revid:jonas@mysql.com-20090509063138-1u3q3v09wnn2txyt) (version source revid:jonas@mysql.com-20090508175813-s6yele2z3oh6o99z) (merge vers: 5.1.33-ndb-6.3.25) (pib:6)
[9 May 2009 18:39]
Bugs System
Pushed into 5.1.34-ndb-7.0.6 (revid:jonas@mysql.com-20090509154927-im9a7g846c6u1hzc) (version source revid:jonas@mysql.com-20090509073226-09bljakh9eppogec) (merge vers: 5.1.33-ndb-7.0.6) (pib:6)
[9 Jun 2009 19:06]
Paul DuBois
Noted in 5.0.74sp1 changelog.