Bug #115365 EXPLAIN ANALYZE: Assertion `ret || !explain_thd->is_error()'
Submitted: 18 Jun 2:02 Modified: 24 Jun 7:52
Reporter: Mikhail Izioumtchenko Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S6 (Debug Builds)
Version:8.4LTS-debug OS:Any
Assigned to: CPU Architecture:Any

[18 Jun 2:02] Mikhail Izioumtchenko
Description:
mysqld: /var/lib/pb2/sb_1-15015186-1712734669.6497831/rpm/BUILD/mysql-8.4.0/mysql-8.4.0/sql/opt_explain.cc:2100: bool explain_query_specification(THD*, const THD*, Query_term*, enum_parsing_context): Assertion `ret || !explain_thd->is_error()' failed.
2024-06-17T14:44:13Z UTC - mysqld got signal 6 ;
Most likely, you have hit a bug, but this error can also be caused by malfunctioning hardware.
BuildID[sha1]=dd647371ab051009e7116042fda15451416fcfb4
Thread pointer: 0x7f8ee5d97da0
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 = 7f8f2270a937 thread_stack 0x100000
 #0 0x35295f5 print_fatal_signal at /usr/src/debug/mysql-community-8.4.0-1.el9.x86_64/mysql-8.4.0/sql/signal_handler.cc:319
 #1 0x3529810 _Z19handle_fatal_signaliP9siginfo_tPv at /usr/src/debug/mysql-community-8.4.0-1.el9.x86_64/mysql-8.4.0/sql/signal_handler.cc:399
 #2 0x7f8f310c86ef <unknown>
...
#8 0x384fd12 _Z27explain_query_specificationP3THDPKS_P10Query_term20enum_parsing_context at /usr/src/debug/mysql-community-8.4.0-1.el9.x86_64/mysql-8.4.0/sql/opt_explain.cc:2100
 #9 0x34614e0 <unknown> at /usr/src/debug/mysql-community-8.4.0-1.el9.x86_64/mysql-8.4.0/sql/sql_union.cc:1515
 #10 0x3461564 <unknown> at /usr/src/debug/mysql-community-8.4.0-1.el9.x86_64/mysql-8.4.0/sql/sql_union.cc:1522
 #11 0x346185b <unknown> at /usr/src/debug/mysql-community-8.4.0-1.el9.x86_64/mysql-8.4.0/sql/sql_union.cc:1587
 #12 0x384fe4f mysql_explain_query_expression at /usr/src/debug/mysql-community-8.4.0-1.el9.x86_64/mysql-8.4.0/sql/opt_explain.cc:2392
 #13 0x38538b5 _Z13explain_queryP3THDPKS_P16Query_expression at /usr/src/debug/mysql-community-8.4.0-1.el9.x86_64/mysql-8.4.0/sql/opt_explain.cc:2353
 #14 0x33e6fa2 _ZN11Sql_cmd_dml13execute_innerEP3THD at /usr/src/debug/mysql-community-8.4.0-1.el9.x86_64/mysql-8.4.0/sql/sql_select.cc:1057
 #15 0x33ea74b _ZN11Sql_cmd_dml7executeEP3THD at /usr/src/debug/mysql-community-8.4.0-1.el9.x86_64/mysql-8.4.0/sql/sql_select.cc:782
 #16 0x338037a _Z21mysql_execute_commandP3THDb at /usr/src/debug/mysql-community-8.4.0-1.el9.x86_64/mysql-8.4.0/sql/sql_parse.cc:4737
 #17 0x33818b6 _Z20dispatch_sql_commandP3THDP12Parser_state at /usr/src/debug/mysql-community-8.4.0-1.el9.x86_64/mysql-8.4.0/sql/sql_parse.cc:5392
 #18 0x3382fae _Z16dispatch_commandP3THDPK8COM_DATA19enum_server_command at /usr/src/debug/mysql-community-8.4.0-1.el9.x86_64/mysql-8.4.0/sql/sql_parse.cc:2136
 #19 0x352f513 _ZN11Srv_session15execute_commandE19enum_server_commandPK8COM_DATAPK12CHARSET_INFOPK22st_command_service_cbs17cs_text_or_binaryPv at /usr/src/debug/mysql-community-8.4.0-1.el9.x86_64/mysql-8.4.0/sql/srv_session.cc:1183
 #20 0x3518314 _Z27command_service_run_commandP11Srv_session19enum_server_commandPK8COM_DATAPK12CHARSET_INFOPK22st_command_service_cbs17cs_text_or_binaryPv at /usr/src/debug/mysql-community-8.4.0-1.el9.x86_64/mysql-8.4.0/sql/command_service.cc:84
 #21 0x4e84ad4 _ZN3xpl16Sql_data_context22execute_server_commandE19enum_server_commandRK8COM_DATAPNS_5iface9ResultsetE at /usr/src/debug/mysql-community-8.4.0-1.el9.x86_64/mysql-8.4.0/plugin/x/src/sql_data_context.cc:637
 #22 0x4e84c0e _ZN3xpl16Sql_data_context11execute_sqlEPKcmPNS_5iface9ResultsetE at /usr/src/debug/mysql-community-8.4.0-1.el9.x86_64/mysql-8.4.0/plugin/x/src/sql_data_context.cc:566
 #23 0x4e848bc _ZN3xpl16Sql_data_context7executeEPKcmPNS_5iface9ResultsetE at /usr/src/debug/mysql-community-8.4.0-1.el9.x86_64/mysql-8.4.0/plugin/x/src/sql_data_context.cc:543
 #24 0x4f1625b _ZN3xpl20Stmt_command_handler16sql_stmt_executeERKN6Mysqlx3Sql11StmtExecuteE at /usr/src/debug/mysql-community-8.4.0-1.el9.x86_64/mysql-8.4.0/plugin/x/src/stmt_command_handler.cc:77
 #25 0x4f163cd _ZN3xpl20Stmt_command_handler7executeERKN6Mysqlx3Sql11StmtExecuteE at /usr/src/debug/mysql-community-8.4.0-1.el9.x86_64/mysql-8.4.0/plugin/x/src/stmt_command_handler.cc:48
 #26 0x4e9af26 _ZN3xpl10Dispatcher8dispatchERKN3ngs15Message_requestE at /usr/src/debug/mysql-community-8.4.0-1.el9.x86_64/mysql-8.4.0/plugin/x/src/xpl_dispatcher.cc:51

How to repeat:
reproducible, see attached SQL
[18 Jun 2:06] Mikhail Izioumtchenko
testcase

Attachment: b.sql (application/octet-stream, text), 48.76 MiB.

[20 Jun 9:39] MySQL Verification Team
Hello Mikhail,

Thank you for the report and test case.
I tried to reproduce using provided test case but not seeing the crash on 8.4.0 release/debug builds. Anything am I  missing here? Thank you.

If you are using the source build then please provide the exact cmake options used for the build. Thank you.

--
bin/mysql -uroot -S/tmp/mysql.sock --force < 115365.sql
.
.
wKLMNOr 65543   19      -45     8.4.0-debug     iklmn01x
col3    col4    col7
56rs231234FVWXYKLMNOBCopqrstu5hijkVWXYZ9AABE2fgOyPQDEFG89vwIJKefgQRS2340956789cdef01234dejQR745678abcdQRSTUBCD01234kLMNOlmnoCGABjklst10lABCDefghiABCDE3abcETUVWXJKLMGHIJKLMNOPOPQRBCTxyz0bcd      0       14397
2024-06-20 11:34:36     11      54
2024-06-20      4       17866
12345XYKLMNOHI72345tuvwx12334abcd2qrst3n0123Z0129nopqrabVWMNO9bcde      0       67
12345yz023459785678xy897lmwxUVWabc0123STU789nopCDEFGklmnnCDEEFGHbcdnopq01BCDQRSTUWXYZrbc456789Aw678stuvwdefgh01201TUVWXz01456vwxyzGHIJKi45678lMrstuv89ABghijkdwxPQtuv67nopqrqrshijkA893456jk      0       46
ERROR 1054 (42S22) at line 11002: Unknown column 'added_col_1564' in 'where clause'

regards,
Umesh
[22 Jun 2:34] Mikhail Izioumtchenko
I can reproduce it reliably with 8.4LTS-debug which I installed from yum repo.
The system is a sandbox over OEL Linux 9 over WSL/Windows 11.
This would not reproduce with non debugging build.
I'm uploading another config file and a simplified testcase:
b1.sql to drop and recreate all tables.
b2.sql a short sequence of EXPLAIN statements.
So it's over empty tables.
It starts with 
SET  explain_format=JSON;

without this SET the assert would not happen.

Another file I'm uploading is b2.out, output of b2.sql execution.
[22 Jun 2:36] Mikhail Izioumtchenko
drop and recreate schemas and tables

Attachment: b1.sql (application/octet-stream, text), 76.37 KiB.

[22 Jun 2:37] Mikhail Izioumtchenko
a few SET and EXPLAIN statements to kill mysqld

Attachment: b2.sql (application/octet-stream, text), 3.42 KiB.

[24 Jun 5:08] MySQL Verification Team
Hello Mikhail Izioumtchenko,

Thank you for the confirmation.
Let me try again and get back to you if anything further needed.

Sincerely,
Umesh
[24 Jun 7:52] MySQL Verification Team
Hello Mikhail,

Thank you for the feedback, with b2.sql I'm able to reproduce.

-
(gdb) bt
#0  0x00007f6150c7058c in __pthread_kill_implementation () from /lib64/libc.so.6
#1  0x000000000428a71a in my_write_core (sig=sig@entry=6) at ../../mysql-8.4.0/mysys/stacktrace.cc:340
#2  0x00000000034c968c in handle_fatal_signal (sig=6, info=0x7f61383f5170, ucontext=0x7f61383f5040) at ../../mysql-8.4.0/sql/signal_handler.cc:407
#3  <signal handler called>
#4  0x00007f6150c7058c in __pthread_kill_implementation () from /lib64/libc.so.6
#5  0x00007f6150c23d06 in raise () from /lib64/libc.so.6
#6  0x00007f6150bf77f3 in abort () from /lib64/libc.so.6
#7  0x00007f6150bf771b in __assert_fail_base.cold () from /lib64/libc.so.6
#8  0x00007f6150c1cca6 in __assert_fail () from /lib64/libc.so.6
#9  0x00000000037a4668 in explain_query_specification (explain_thd=explain_thd@entry=0x7f60b416b830, query_thd=query_thd@entry=0x7f60b416b830, query_term=query_term@entry=0x7f60b5de55a8, ctx=ctx@entry=CTX_JOIN)
    at ../../mysql-8.4.0/sql/opt_explain.cc:2100
#10 0x0000000003413356 in Query_expression::explain_query_term (this=0x7f60b5de54c0, explain_thd=0x7f60b416b830, query_thd=0x7f60b416b830, qt=0x7f60b5de55a8) at ../../mysql-8.4.0/sql/sql_union.cc:1515
#11 0x00000000034133da in Query_expression::explain_query_term (this=this@entry=0x7f60b5de54c0, explain_thd=explain_thd@entry=0x7f60b416b830, query_thd=query_thd@entry=0x7f60b416b830, qt=0x7f60b5e3c1c8)
    at ../../mysql-8.4.0/sql/sql_union.cc:1522
#12 0x00000000034136b9 in Query_expression::explain (this=this@entry=0x7f60b5de54c0, explain_thd=explain_thd@entry=0x7f60b416b830, query_thd=query_thd@entry=0x7f60b416b830) at ../../mysql-8.4.0/sql/sql_union.cc:1587
#13 0x00000000037a476a in mysql_explain_query_expression (explain_thd=explain_thd@entry=0x7f60b416b830, query_thd=query_thd@entry=0x7f60b416b830, unit=unit@entry=0x7f60b5de54c0) at ../../mysql-8.4.0/sql/opt_explain.cc:2392
#14 0x00000000037a7ea9 in explain_query (explain_thd=explain_thd@entry=0x7f60b416b830, query_thd=query_thd@entry=0x7f60b416b830, unit=unit@entry=0x7f60b5de54c0) at ../../mysql-8.4.0/sql/opt_explain.cc:2353
#15 0x00000000033a35b5 in Sql_cmd_dml::execute_inner (this=<optimized out>, thd=0x7f60b416b830) at ../../mysql-8.4.0/sql/sql_select.cc:1057
#16 0x00000000033a6bab in Sql_cmd_dml::execute (this=0x7f60b5e3da48, thd=0x7f60b416b830) at ../../mysql-8.4.0/sql/sql_select.cc:782
#17 0x0000000003344dee in mysql_execute_command (thd=thd@entry=0x7f60b416b830, first_level=first_level@entry=true) at ../../mysql-8.4.0/sql/sql_parse.cc:4737
#18 0x0000000003346289 in dispatch_sql_command (thd=0x7f60b416b830, parser_state=parser_state@entry=0x7f61383f7ba0) at ../../mysql-8.4.0/sql/sql_parse.cc:5392
#19 0x000000000334794f in dispatch_command (thd=<optimized out>, thd@entry=0x7f60b416b830, com_data=com_data@entry=0x7f61383f89e0, command=COM_QUERY) at ../../mysql-8.4.0/sql/sql_parse.cc:2136
#20 0x00000000033492e3 in do_command (thd=thd@entry=0x7f60b416b830) at ../../mysql-8.4.0/sql/sql_parse.cc:1465
#21 0x00000000034bac2a in handle_connection (arg=arg@entry=0xb114410) at ../../mysql-8.4.0/sql/conn_handler/connection_handler_per_thread.cc:304
#22 0x0000000004aa7ba0 in pfs_spawn_thread (arg=0xb2a2760) at ../../../mysql-8.4.0/storage/perfschema/pfs.cc:3051
#23 0x00007f6150c6e812 in start_thread () from /lib64/libc.so.6
#24 0x00007f6150c0e450 in clone3 () from /lib64/libc.so.6
(gdb)

regards,
Umesh