Bug #53103 | MTR test ps crashes in optimize_cond() when running with --debug | ||
---|---|---|---|
Submitted: | 23 Apr 2010 9:34 | Modified: | 23 Nov 2010 3:24 |
Reporter: | Olav Sandstå | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 6.0.14 | OS: | Any |
Assigned to: | Jørgen Løland | CPU Architecture: | Any |
Tags: | materialization, optimizer_switch |
[23 Apr 2010 9:34]
Olav Sandstå
[23 Apr 2010 10:12]
Olav Sandstå
Running the ps test with --debug on Linux also results in the same crash.
[23 Apr 2010 10:35]
Olav Sandstå
Running the test with Valgrind produces the following error report: ==20069== Thread 4: ==20069== Invalid read of size 8 ==20069== at 0x78EB94: Item_ref::print(String*, enum_query_type) (item.cc:643 6) ==20069== by 0x7C7AF7: Item_func::print_op(String*, enum_query_type) (item_fu nc.cc:448) ==20069== by 0x7AE656: Item_bool_func2::print(String*, enum_query_type) (item _cmpfunc.h:367) ==20069== by 0x7A05A1: Item_cond::print(String*, enum_query_type) (item_cmpfu nc.cc:4446) ==20069== by 0x61B62E: st_select_lex::print(THD*, String*, enum_query_type) ( sql_select.cc:22868) ==20069== by 0x7F06B2: subselect_single_select_engine::print(String*, enum_qu ery_type) (item_subselect.cc:2840) ==20069== by 0x7F038C: subselect_hash_sj_engine::print(String*, enum_query_ty pe) (item_subselect.cc:3376) ==20069== by 0x7F042D: Item_subselect::print(String*, enum_query_type) (item_ subselect.cc:396) ==20069== by 0x7F05C6: Item_in_subselect::print(String*, enum_query_type) (it em_subselect.cc:1794) ==20069== by 0x7C6016: Item_func::print_args(String*, unsigned, enum_query_ty pe) (item_func.cc:438) ==20069== by 0x7C7C0D: Item_func::print(String*, enum_query_type) (item_func. cc:427) ==20069== by 0x7A05FE: Item_cond::print(String*, enum_query_type) (item_cmpfu nc.cc:4452) ==20069== by 0x686F59: print_where(Item*, char const*, enum_query_type) (sql_ test.cc:68) ==20069== by 0x63C5C7: optimize_cond(JOIN*, Item*, List<TABLE_LIST>*, bool, I tem::cond_result*) (sql_select.cc:13781) ==20069== by 0x643E78: JOIN::optimize() (sql_select.cc:1562) ==20069== by 0x649258: mysql_select(THD*, Item***, TABLE_LIST*, unsigned, Lis t<Item>&, Item*, unsigned, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) (sql_select.cc:3229) ==20069== Address 0x9AA5998 is 24 bytes inside a block of size 256 free'd ==20069== at 0x4A0541E: free (vg_replace_malloc.c:233) ==20069== by 0xA60C85: my_no_flags_free (my_malloc.c:66) ==20069== by 0xA5613F: free_root (my_alloc.c:349) ==20069== by 0x5F78D1: dispatch_command(enum_server_command, THD*, char*, uns igned) (sql_parse.cc:1533) ==20069== by 0x5F7B30: do_command(THD*) (sql_parse.cc:838) ==20069== by 0x6D545F: do_handle_one_connection(THD*) (sql_connect.cc:1187) ==20069== by 0x6D5524: handle_one_connection (sql_connect.cc:1127) ==20069== by 0xA36127: pfs_spawn_thread(void*) (pfs.cc:1012) ==20069== by 0x30242062F6: start_thread (in /lib64/libpthread-2.5.so) ==20069== by 0x30236D1B6C: clone (in /lib64/libc-2.5.so)
[23 Apr 2010 10:58]
MySQL Verification Team
Thank you for the bug report. Verified on FC 12 X86_64: [miguel@tikal mysql-test]$ ./mtr --debug ps Logging: ./mtr --debug ps 100423 7:55:29 [Note] Buffered information: Performance schema disabled (reason: start parameters). 100423 7:55:29 [Note] Plugin 'FEDERATED' is disabled. 100423 7:55:29 [Note] Plugin 'ndbcluster' is disabled. MySQL Version 6.0.14 Checking supported features... - using ndbcluster when necessary, mysqld supports it - SSL connections supported - binaries are debug compiled Collecting tests... vardir: /home/miguel/bzr/6.0-codebase/mysql-test/var Removing old var directory... Creating var directory '/home/miguel/bzr/6.0-codebase/mysql-test/var'... Installing system database... Using server port 59728 ============================================================================== TEST RESULT TIME (ms) ------------------------------------------------------------ worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009 main.ps [ fail ] Test ended at 2010-04-23 07:55:42 CURRENT_TEST: main.ps mysqltest: At line 1058: query 'EXECUTE STMT USING @id,@id' failed: 2013: Lost connection to MySQL server during query The result from queries just before the failure was:
[23 Apr 2010 11:00]
Valeriy Kravchuk
Verified just as described on 32-bit Ubuntu 8.04 (not a cmake build, just usual BUILD/compile-pentium-debug-max script was used): openxs@ubuntu:/home2/openxs/dbs/6.0-bugfixing/mysql-test$ ./mtr --debug ps Logging: ./mtr --debug ps 100423 13:55:36 [Note] Buffered information: Performance schema disabled (reason: start parameters). 100423 13:55:36 [Note] Plugin 'FEDERATED' is disabled. 100423 13:55:36 [Note] Plugin 'ndbcluster' is disabled. MySQL Version 6.0.14 Checking supported features... - using ndbcluster when necessary, mysqld supports it - SSL connections supported - binaries are debug compiled Collecting tests... vardir: /home2/openxs/dbs/6.0-bugfixing/mysql-test/var Checking leftover processes... Removing old var directory... Creating var directory '/home2/openxs/dbs/6.0-bugfixing/mysql-test/var'... Installing system database... Using server port 52563 worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009 ============================================================================== TEST RESULT TIME (ms) ------------------------------------------------------------ main.ps [ fail ] Test ended at 2010-04-23 13:56:04 CURRENT_TEST: main.ps mysqltest: At line 1058: query 'EXECUTE STMT USING @id,@id' failed: 2013: Lost connection to MySQL server during query The result from queries just before the failure was: < snip > ('444444', 'Enrolled', '2006-03-01', 'CAD' ), ('555555', 'Disenrolled', '2006-03-01', 'CAD' ), ('555555', 'Enrolled', '2006-07-21', 'CAD' ), ('555555', 'Disenrolled', '2006-03-01', 'CHF' ), ('666666', 'Enrolled', '2006-02-09', 'CAD' ), ('666666', 'Enrolled', '2006-05-12', 'CHF' ), ('666666', 'Disenrolled', '2006-06-01', 'CAD' ); PREPARE STMT FROM "SELECT GROUP_CONCAT(Track SEPARATOR ', ') FROM t1 WHERE Member_ID=? AND Action='Enrolled' AND (Track,Action_Date) IN (SELECT Track, MAX(Action_Date) FROM t1 WHERE Member_ID=? GROUP BY Track HAVING Track>='CAD' AND MAX(Action_Date)>'2006-03-01')"; SET @id='111111'; EXECUTE STMT USING @id,@id; GROUP_CONCAT(Track SEPARATOR ', ') NULL SET @id='222222'; More results from queries before failure can be found in /home2/openxs/dbs/6.0-bugfixing/mysql-test/var/log/ps.log Server [mysqld.1 - pid: 9990, winpid: 9990, exit: 256] failed during test run Server log from this test: 100423 13:55:43 [Note] Buffered information: Performance schema enabled. 100423 13:55:43 [Note] Plugin 'FEDERATED' is disabled. 100423 13:55:43 [Note] Plugin 'InnoDB' is disabled. 100423 13:55:43 [Note] Plugin 'ndbcluster' is disabled. 100423 13:55:44 [Note] Event Scheduler: Loaded 0 events 100423 13:55:44 [Note] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld: ready for connections. Version: '6.0.14-alpha-debug-log' socket: '/home2/openxs/dbs/6.0-bugfixing/mysql-test/var/tmp/mysqld.1.sock' port: 13000 Source distribution 100423 13:55:59 - 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=1048576 read_buffer_size=131072 max_used_connections=2 max_threads=151 thread_count=1 connection_count=1 It is possible that mysqld could use up to key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 60134 K bytes of memory Hope that's ok; if not, decrease some variables in the equation. thd: 0x9145408 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 = 0xb3471f60 thread_stack 0x30c00 /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(my_print_stacktrace+0x32) [0x87c109d] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(handle_segfault+0x2f2) [0x8310138] [0xb7713420] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(Item_func::print_op(String*, enum_query_type)+0x63) [0x82649bb] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(Item_bool_func2::print(String*, enum_query_type)+0x1f) [0x828a96f] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(Item_cond::print(String*, enum_query_type)+0x75) [0x827d521] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(st_select_lex::print(THD*, String*, enum_query_type)+0x52c) [0x83a21d0] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(subselect_single_select_engine::print(String*, enum_query_type)+0x2c) [0x82b9ef4] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(subselect_hash_sj_engine::print(String*, enum_query_type)+0x47) [0x82b9ba1] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(Item_subselect::print(String*, enum_query_type)+0x49) [0x82b9c47] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(Item_in_subselect::print(String*, enum_query_type)+0x93) [0x82b9e0b] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(Item_func::print_args(String*, unsigned int, enum_query_type)+0x67) [0x8262e85] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(Item_func::print(String*, enum_query_type)+0x5d) [0x8264ad7] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(Item_cond::print(String*, enum_query_type)+0xe2) [0x827d58e] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(print_where(Item*, char const*, enum_query_type)+0x9a) [0x83fe8de] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld [0x83b9a3b] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(JOIN::optimize()+0x3a2) [0x83c8adc] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(mysql_select(THD*, Item***, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*)+0x283) [0x83cd5a5] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(handle_select(THD*, LEX*, select_result*, unsigned long)+0x1ec) [0x83d316a] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld [0x83224d9] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(mysql_execute_command(THD*)+0xa7a) [0x83243b8] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(Prepared_statement::execute(String*, bool)+0x468) [0x83e68de] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(Prepared_statement::execute_loop(String*, bool, unsigned char*, unsigned char*)+0xf7) [0x83ea547] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(mysql_sql_stmt_execute(THD*)+0x180) [0x83ea7de] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(mysql_execute_command(THD*)+0xaa9) [0x83243e7] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(mysql_parse(THD*, char const*, unsigned int, char const**)+0x229) [0x832cec7] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(dispatch_command(enum_server_command, THD*, char*, unsigned int)+0x9e9) [0x832da45] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(do_command(THD*)+0x241) [0x832efa5] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(do_handle_one_connection(THD*)+0x150) [0x831b31c] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(handle_one_connection+0x25) [0x831b3db] /home2/openxs/dbs/6.0-bugfixing/libexec/mysqld(pfs_spawn_thread(void*)+0xb8) [0x8857686] /lib/tls/i686/cmov/libpthread.so.0 [0xb76e84fb] /lib/tls/i686/cmov/libc.so.6(clone+0x5e) [0xb74f7e5e] Trying to get some variables. Some pointers may be invalid and cause the dump to abort... thd->query at 0x915af58 = SELECT GROUP_CONCAT(Track SEPARATOR ', ') FROM t1 WHERE Member_ID='222222' AND Action='Enrolled' AND (Track,Action_Date) IN (SELECT Track, MAX(Action_Date) FROM t1 WHERE Member_ID='222222' GROUP BY Track HAVING Track>='CAD' AND MAX(Action_Date)>'2006-03-01') thd->thread_id=2 thd->killed=NOT_KILLED
[25 May 2010 12:21]
Guilhem Bichot
smaller testcase: run this with --debug: CREATE TABLE t1(Track varchar(15)); INSERT INTO t1 VALUES ('CAD'), ('CAD'); PREPARE STMT FROM "SELECT 1 FROM t1 WHERE Track IN (SELECT Track FROM t1 GROUP BY Track HAVING Track>='CAD')"; EXECUTE STMT ; EXECUTE STMT ; DEALLOCATE PREPARE STMT; DROP TABLE t1;
[25 May 2010 13:16]
Guilhem Bichot
goes away with materialization=off (subquery mat, not semijoin mat)
[28 May 2010 14:37]
Guilhem Bichot
as this is not a genuine regression, I go back to BKA-with-semijoin bugs as planned.
[9 Jun 2010 8:03]
Jørgen Løland
The problem is that JOIN::prepare is not called for the subquery on second execution of the PS. Because the subquery is not reprepared, the Item_ref for 'Track' in the having clause refers to a temporary Item_field created by change_to_use_tmp_fields() during JOIN::exec of the first PS execution. This temporary Item_field is now invalid. The suggested fix is to prepare the subquery on all PS executions so that the fields are resolved. For subselect_single_select_engine, this is done in prepare(). In this bug, hash_sj_engine is used, and it seems like it was designed to reuse subselect_single_select_engine::prepare(): From item_subselect.h: class subselect_hash_sj_engine: public subselect_uniquesubquery_engine ... /* The old engine already chosen at parse time and stored in permanent memory. Through this member we can re-create and re-prepare materialize_join for each execution of a prepared statement. We akso resuse the functionality of subselect_single_select_engine::[prepare | cols]. */ ... however, prepare() is not reused in the implementation, which reads: int prepare() { return 0; }
[9 Jun 2010 12:15]
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/110614 3188 Jorgen Loland 2010-06-09 BUG#53103 - MTR test ps crashes in optimize_cond() when running with --debug The problem was that when subselect_hash_sj_engine was used to materialize a subselect, the subselect was not prepared for each execution of a PS. Because of this, Items in the subselect were not fixed on the second execution of the PS. The fix is to call materialize_engine->prepare() in subselect_hash_sj_engine::prepare() method. From comments in the class, this seems to have been the intention all along. @ mysql-test/r/subselect_sj_debug.result Add test for BUG#53103 @ mysql-test/t/subselect_sj_debug.test Add test for BUG#53103 @ sql/item_subselect.h Make subselect_hash_sj_engine::prepare() reuse subselect_single_select_engine::prepare() so that the subselect gets reprepared on each PS execution.
[14 Jun 2010 7:00]
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/110968 3193 Jorgen Loland 2010-06-14 BUG#53103 - MTR test ps crashes in optimize_cond() when running with --debug The problem was that when subselect_hash_sj_engine was used to materialize a subselect, the subselect was not prepared for each execution of a PS. Because of this, Items in the subselect were not fixed on the second execution of the PS. The fix is to call materialize_engine->prepare() in subselect_hash_sj_engine::prepare() method. From comments in the class, this seems to have been the intention all along. @ mysql-test/r/subselect_sj2.result Add test for BUG#53103 @ mysql-test/t/subselect_sj2.test Add test for BUG#53103 @ sql/item_subselect.h Make subselect_hash_sj_engine::prepare() reuse subselect_single_select_engine::prepare() so that the subselect gets reprepared on each PS execution.
[14 Jun 2010 7:11]
Jørgen Løland
Pushed to opt-backporting
[14 Jun 2010 7:57]
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/110977 3196 Jorgen Loland 2010-06-14 BUG#53103 - MTR test ps crashes in optimize_cond() when running with --debug Move test from subselect_sj2 to subselect4. @ mysql-test/r/subselect4.result Move test from subselect_sj2 to subselect4. @ mysql-test/r/subselect_sj2.result Move test from subselect_sj2 to subselect4. @ mysql-test/t/subselect4.test Move test from subselect_sj2 to subselect4. @ mysql-test/t/subselect_sj2.test Move test from subselect_sj2 to subselect4.
[16 Aug 2010 6:42]
Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100816062819-bluwgdq8q4xysmlg) (version source revid:alik@sun.com-20100816062612-enatdwnv809iw3s9) (pib:20)
[13 Nov 2010 16:13]
Bugs System
Pushed into mysql-trunk 5.6.99-m5 (revid:alexander.nozdrin@oracle.com-20101113155825-czmva9kg4n31anmu) (version source revid:vasil.dimov@oracle.com-20100629074804-359l9m9gniauxr94) (merge vers: 5.6.99-m4) (pib:21)
[23 Nov 2010 3:24]
Paul DuBois
Bug does not appear in any released 5.6.x version. No 5.6.1 changelog entry needed.