Bug #114779 lost connection in MySQL NDB cluster
Submitted: 25 Apr 8:32 Modified: 25 Apr 12:13
Reporter: CunDi Fang Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:8.0.35-cluster MySQL Cluster Community S OS:Any (20.04)
Assigned to: MySQL Verification Team CPU Architecture:Any

[25 Apr 8:32] CunDi Fang
Description:
Hello, I found a bug in 8.0.35-cluster version of MYSQL cluster. It will cause the current mysql service to crash.

It's very similar to bug #114773, and I doubt it's the same piece of code that's at fault.

The detail is as follow.

OS version and name:
Ubuntu 22.04.3 LTS (Jammy Jellyfish)
Linux eb1f47b08982 6.5.11-8-pve #1 SMP PREEMPT_DYNAMIC PMX 6.5.11-8 (2024-01-30T12:27Z) x86_64 x86_64 x86_64 GNU/Linux

Poc:

```
select
  subq_1.c0 as c0,
  subq_1.c0 as c1,
  case when (false)
      and (((false)
          or (false))
        and (true)) then subq_1.c0 else subq_1.c0 end
     as c2,
  subq_1.c0 as c3,
  subq_1.c0 as c4,
  subq_1.c0 as c5,
  subq_1.c0 as c6
from
  (select
        ref_0.column6 as c0
      from
        mytest90.test3 as ref_0
          right join (select
                ref_2.column7 as c0,
                ref_2.column6 as c1,
                ref_1.column5 as c2,
                ref_1.column1 as c3,
                ref_1.column1 as c4,
                ref_1.column5 as c5
              from
                mytest90.test7 as ref_1
                  left join mytest90.test7 as ref_2
                  on ((ref_2.column6 is not NULL)
                      and ((ref_2.column6 is not NULL)
                        or (false)))
              where (((false)
                    or (false))
                  and (EXISTS (
                    select
                        ref_1.column6 as c0,
                        ref_3.column1 as c1,
                        ref_3.column1 as c2,
                        ref_2.column2 as c3
                      from
                        mytest90.test6 as ref_3
                      where true
                      limit 185)))
                or (ref_1.column1 is NULL)
              limit 89) as subq_0
          on ((false)
              and (false))
      where ref_0.column1 is NULL
      limit 116) as subq_1
where false
limit 149;
```
It manifests itself in this way:

```
ERROR 2013 (HY000): Lost connection to MySQL server during query
No connection. Trying to reconnect...
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/usr/local/mysql-cluster/sock/mysql.sock' (111)
ERROR: 
Can't connect to the server
```

Architecture Information:
'''
[NDBD DEFAULT]
NoOfReplicas =2
DataMemory = 512M
IndexMemory = 64M

[NDB_MGMD]
NodeId=1
hostname =192.172.10.8
datadir =/var/lib/mysql-cluster

[NDBD]
NodeId =2
hostname =192.172.10.9
datadir =/usr/local/mysql-cluster/data
NodeGroup=0
[NDBD]
NodeId =3
hostname =192.172.10.10
datadir =/usr/local/mysql-cluster/data
NodeGroup=1
[NDBD]
NodeId =4
hostname =192.172.10.11
datadir =/usr/local/mysql-cluster/data
NodeGroup=0
[NDBD]
NodeId =5
hostname =192.172.10.12
datadir =/usr/local/mysql-cluster/data
NodeGroup=1

[mysqld]
NodeId =6
hostname =192.172.10.9
[mysqld]
NodeId =7
hostname =192.172.10.10
[mysqld]
NodeId =8
hostname =192.172.10.11
[mysqld]
NodeId =9
hostname =192.172.10.12
'''

Attempted and successfully reproduced!

How to repeat:
Importing the database file I give later, and then executing Poc

Suggested fix:
The reason this bug is strange, and the reason why I say he and bug #114773 are similar rather than equivalent, is that he is a SELECT statement, not a DELETE statement that would make changes to the data that would require synchronized operations, so it's possible that he's causing the mysql service to crash for a different reason.
[25 Apr 12:13] MySQL Verification Team
It is the same underlying condition that causes the problem

Duplicate of Bug #114464