Bug #119772 [8.0.45-debug] Lost connection to MySQL server during query
Submitted: 25 Jan 11:30 Modified: 25 Jan 21:06
Reporter: Chunling Qin Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: DML Severity:S2 (Serious)
Version:8.0.45 OS:CentOS
Assigned to: CPU Architecture:Any

[25 Jan 11:30] Chunling Qin
Description:
mysql> CREATE TABLE t0 (c0 SMALLINT UNSIGNED);
ERROR 1050 (42S01): Table 't0' already exists
mysql> SELECT ALL t0.c0 AS ref0 FROM t0 WHERE ((! ((-1030413543) NOT IN (t0.c0)))) && ((+ (LEAST(t0.c0, t0.c0)))) ;

ERROR 2013 (HY000): Lost connection to MySQL server during query
No connection. Trying to reconnect...
ERROR 2003 (HY000): Can't connect to MySQL server on '9.30.1.48:3306' (111)
ERROR: 
Can't connect to the server

In the log, we found the following message:
#8 0x55680b370e4f _ZN17Item_func_min_max6int_opEv at /data/mysql-server/sql/item_func.cc:3937
 #9 0x55680b363b4d _ZN19Item_func_numhybrid7val_intEv at /data/mysql-server/sql/item_func.cc:1731
 #10 0x55680b3714cc _ZN17Item_func_min_max7val_intEv at /data/mysql-server/sql/item_func.cc:3983
 #11 0x55680b2d213d _ZN14Arg_comparator27compare_int_signed_unsignedEv at /data/mysql-server/sql/item_cmpfunc.cc:1927
 #12 0x55680b2f7c7f _ZN14Arg_comparator7compareEv at /data/mysql-server/sql/item_cmpfunc.h:211
 #13 0x55680b2d6f3f _ZN12Item_func_ne7val_intEv at /data/mysql-server/sql/item_cmpfunc.cc:2502
 #14 0x55680b2848d5 _ZN4Item8val_boolEv at /data/mysql-server/sql/item.cc:219
 #15 0x55680b35be82 _Z15eval_const_condP3THDP4ItemPb at /data/mysql-server/sql/item_func.cc:309
 #16 0x55680ac1db26 _Z15remove_eq_condsP3THDP4ItemPS2_PNS1_11cond_resultE at /data/mysql-server/sql/sql_optimizer.cc:10582
 #17 0x55680ac1d7c8 _Z15remove_eq_condsP3THDP4ItemPS2_PNS1_11cond_resultE at /data/mysql-server/sql/sql_optimizer.cc:10508
 #18 0x55680ac15943 _Z13optimize_condP3THDPP4ItemPP10COND_EQUALP14mem_root_dequeIP9Table_refEPNS1_11cond_resultE at /data/mysql-server/sql/sql_optimizer.cc:10449
 #19 0x55680ac114b8 _ZN4JOIN8optimizeEb at /data/mysql-server/sql/sql_optimizer.cc:473
 #20 0x55680ad3a8f4 _ZN11Query_block8optimizeEP3THDb at /data/mysql-server/sql/sql_select.cc:2001
 #21 0x55680ae3b22a _ZN16Query_expression8optimizeEP3THDP5TABLEbb at /data/mysql-server/sql/sql_union.cc:1019
 #22 0x55680ad374df _ZN11Sql_cmd_dml13execute_innerEP3THD at /data/mysql-server/sql/sql_select.cc:999
 #23 0x55680ad36207 _ZN11Sql_cmd_dml7executeEP3THD at /data/mysql-server/sql/sql_select.cc:785
 #24 0x55680ac72a25 _Z21mysql_execute_commandP3THDb at /data/mysql-server/sql/sql_parse.cc:4724
 #25 0x55680ac660ea _Z20dispatch_sql_commandP3THDP12Parser_state at /data/mysql-server/sql/sql_parse.cc:5385
 #26 0x55680ac60d05 _Z16dispatch_commandP3THDPK8COM_DATA19enum_server_command at /data/mysql-server/sql/sql_parse.cc:2055
 #27 0x55680ac6415e _Z10do_commandP3THD at /data/mysql-server/sql/sql_parse.cc:1440
 #28 0x55680af7b7f1 _ZL17handle_connectionPv at /data/mysql-server/sql/conn_handler/connection_handler_per_thread.cc:303
 #29 0x55680deb4eb9 _ZL16pfs_spawn_threadPv at /data/mysql-server/storage/perfschema/pfs.cc:3050
 #30 0x7f51a7a75276 <unknown>
 #31 0x7f51a7afc83b <unknown>
 #32 0xffffffffffffffff <unknown>

How to repeat:
CREATE TABLE t0 (c0 SMALLINT UNSIGNED);
SELECT ALL t0.c0 AS ref0 FROM t0 WHERE ((! ((-1030413543) NOT IN (t0.c0)))) && ((+ (LEAST(t0.c0, t0.c0)))) ;
[25 Jan 13:47] Daniël van Eeden
Ran this through c++filt to make it readable:

 #8 0x55680b370e4f Item_func_min_max::int_op() at /data/mysql-server/sql/item_func.cc:3937
 #9 0x55680b363b4d Item_func_numhybrid::val_int() at /data/mysql-server/sql/item_func.cc:1731
 #10 0x55680b3714cc Item_func_min_max::val_int() at /data/mysql-server/sql/item_func.cc:3983
 #11 0x55680b2d213d Arg_comparator::compare_int_signed_unsigned() at /data/mysql-server/sql/item_cmpfunc.cc:1927
 #12 0x55680b2f7c7f Arg_comparator::compare() at /data/mysql-server/sql/item_cmpfunc.h:211
 #13 0x55680b2d6f3f Item_func_ne::val_int() at /data/mysql-server/sql/item_cmpfunc.cc:2502
 #14 0x55680b2848d5 Item::val_bool() at /data/mysql-server/sql/item.cc:219
 #15 0x55680b35be82 eval_const_cond(THD*, Item*, bool*) at /data/mysql-server/sql/item_func.cc:309
 #16 0x55680ac1db26 remove_eq_conds(THD*, Item*, Item**, Item::cond_result*) at /data/mysql-server/sql/sql_optimizer.cc:10582
 #17 0x55680ac1d7c8 remove_eq_conds(THD*, Item*, Item**, Item::cond_result*) at /data/mysql-server/sql/sql_optimizer.cc:10508
 #18 0x55680ac15943 optimize_cond(THD*, Item**, COND_EQUAL**, mem_root_deque<Table_ref*>*, Item::cond_result*) at /data/mysql-server/sql/sql_optimizer.cc:10449
 #19 0x55680ac114b8 JOIN::optimize(bool) at /data/mysql-server/sql/sql_optimizer.cc:473
 #20 0x55680ad3a8f4 Query_block::optimize(THD*, bool) at /data/mysql-server/sql/sql_select.cc:2001
 #21 0x55680ae3b22a Query_expression::optimize(THD*, TABLE*, bool, bool) at /data/mysql-server/sql/sql_union.cc:1019
 #22 0x55680ad374df Sql_cmd_dml::execute_inner(THD*) at /data/mysql-server/sql/sql_select.cc:999
 #23 0x55680ad36207 Sql_cmd_dml::execute(THD*) at /data/mysql-server/sql/sql_select.cc:785
 #24 0x55680ac72a25 mysql_execute_command(THD*, bool) at /data/mysql-server/sql/sql_parse.cc:4724
 #25 0x55680ac660ea dispatch_sql_command(THD*, Parser_state*) at /data/mysql-server/sql/sql_parse.cc:5385
 #26 0x55680ac60d05 dispatch_command(THD*, COM_DATA const*, enum_server_command) at /data/mysql-server/sql/sql_parse.cc:2055
 #27 0x55680ac6415e do_command(THD*) at /data/mysql-server/sql/sql_parse.cc:1440
 #28 0x55680af7b7f1 handle_connection(void*) at /data/mysql-server/sql/conn_handler/connection_handler_per_thread.cc:303
 #29 0x55680deb4eb9 pfs_spawn_thread(void*) at /data/mysql-server/storage/perfschema/pfs.cc:3050
 #30 0x7f51a7a75276 <unknown>
 #31 0x7f51a7afc83b <unknown>
 #32 0xffffffffffffffff <unknown>
[25 Jan 21:06] Roy Lyseng
Thank you for the bug report.
However, this looks like a duplicate of bug#119639.
[26 Jan 11:47] Daniël van Eeden
> However, this looks like a duplicate of bug#119639.

So bug#119772 is a duplicate of bug#119639 ?
And bug#119639 itself is a duplicate of bug#119606 ?
And bug#119606 is also a duplicate? But without info about what bug it duplicates?

Bug #119772 (Status: Duplicate)
     |
  duplicates
     |
     V
Bug #119639 (Status: Duplicate)
     |
  duplicates
     |
     V
Bug #119606 (Status: Duplicate)
     |
  duplicates
     |
     V
Unknown Bug?
[26 Jan 13:22] Jean-François Gagné
> > However, this looks like a duplicate of bug#119639.
>
> Bug #119639 (Status: Duplicate)
>      |
>   duplicates
>      |
>      V
> Bug #119606 (Status: Duplicate)

I agree with Daninël, instead of flagging this bug as a duplicate of bug#119639, it should have been flagged as a duplicate of Bug #119606.

> Bug #119606 (Status: Duplicate)
>     |
>  duplicates
>     |
>     V
> Unknown Bug?

Right, it is easy to miss in Bug#119606, I copied below.

> [16 Jan 12:43] Knut Anders Hatlen
>
> Posted by developer:
>
> Closing as duplicate of Bug#37083848 (virtual longlong Item_func_min_max::int_op(): [...]) which was fixed in MySQL 9.2.0.

It is weird to point a public bug as a duplicate of a private fixed bug, hopefully a better way will be found to handle such case.

As I posted in Bug#119639 and Bug#37083848, even though this was fixed in 9.2, 8.4.8 and in 8.0.45 are still affected.
[26 Jan 13:23] Jean-François Gagné
> As I posted in Bug#119639 and Bug#37083848

Sorry, above should have been "As I posted in Bug#119639 and Bug#119606".