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

[25 Apr 2024 6:13] 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.

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:

```
delete from mytest90.test9
where 
EXISTS (
  select
      ref_0.column1 as c0,
      (select node_id from ndbinfo.cpuinfo limit 1 offset 6)
         as c1,
      subq_0.c1 as c2,
      ref_0.column2 as c3,
      case when (false)          or (false) then 21 else 21 end
         as c4
    from
      mytest90.test1 as ref_0
        right join (select
              (select mysql_version from sys.version limit 1 offset 48)
                 as c0,
              ref_1.column6 as c1,
              (select LOCK_DATA from performance_schema.data_locks limit 1 offset 4)
                 as c2,
              mytest90.test9.column5 as c3,
              ref_1.column4 as c4,
              ref_1.column5 as c5
            from
              mytest90.test4 as ref_1            where ref_1.column6 is NULL) as subq_0
        on (false)
    where (true)
      and ((true)
        or ((mytest90.test9.column8 is not NULL)
          and ((false)
            or ((mytest90.test9.column10 is not NULL)
              or ((true)
                and (EXISTS (
                  select
                      subq_0.c2 as c0,
                      subq_0.c2 as c1,
                      ref_0.column2 as c2,
                      ref_2.column1 as c3
                    from
                      mytest90.test3 as ref_2
                    where subq_0.c1 is NULL
                    limit 150)))))))
limit 120);
```
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:
I'm not sure why this issue is occurring, but since there are multiple layers of nested queries and EXISTS clauses involved, it may be that there is a problem with the synchronization process?
[25 Apr 2024 12:13] MySQL Verification Team
Hi,

This is again the same underlying issue as 114464. We do not mind multiple submissions but please upload ndb_error_reporter output or collect all the logs from all the nodes, zip to a file and upload to the issue. 

Duplicate of Bug #114464
[25 Apr 2024 12:15] MySQL Verification Team
Please use ndb_error_reporter to collect all the required log files https://dev.mysql.com/doc/refman/8.0/en/mysql-cluster-programs-ndb-error-reporter.html 

Duplicate of Bug #114464
[26 Apr 2024 20:51] MySQL Verification Team
Hi,
Yes, thanks, ndb_error_report log file help us solve this. Even as all these are duplicates from same underlying condition, multiple log files help us solve the issue faster.