title: Error 2013: Lost connection to MySQL server during query when dumping table
body: <p>Please help,I created a stored procedure with the following content:</p>
  
  <pre><code>delimiter $$
  CREATE PROCEDURE inst_para_select(IN n int)
  BEGIN    
      DECLARE i INT DEFAULT 1;
      WHILE i &lt;= n  DO
          INSERT INTO `para_select` VALUES(i,CONCAT(i,'_test'),NOW());
          SET i = i+1;
      END WHILE;
  END $$
  delimiter;
  
  </code></pre>
  
  <p>Execute the procedure:</p>
  
  <pre><code>mysql&gt; call inst_para_select(50000000);
  </code></pre>
  
  <p>After running for about 3 hours, I found that the execution of the  procedure failed, prompting: </p>
  
  <pre><code>mysql&gt; call inst_para_select(50000000);
   ERROR 2013 (HY000): Lost connection to MySQL server during query
  </code></pre>
  
  <p>Connect the table and database status again and find the following error:</p>
  
  <pre><code>mysql&gt; select count(1) from para_rel;
  ERROR 2006 (HY000): MySQL server has gone away
  No connection. Trying to reconnect...
  Connection id:    8
  Current database: music
  
  ERROR 2013 (HY000): Lost connection to MySQL server during query
  </code></pre>
  
  <p>After querying the logs, it was found that the database was down and restarted:</p>
  
  <pre><code>mysql&gt;  show global status like 'uptime';
  ERROR 2006 (HY000): MySQL server has gone away
  No connection. Trying to reconnect...
  Connection id:    8
  Current database: music
  
  +---------------+-------+
  | Variable_name | Value |
  +---------------+-------+
  | Uptime        | 42    |
  +---------------+-------+
  1 row in set (0.03 sec)
  </code></pre>
  
  <p>Running the check table command also fails：</p>
  
  <pre><code>mysql&gt; use music;
  Reading table information for completion of table and column names
  You can turn off this feature to get a quicker startup with -A
  
  Database changed
  mysql&gt; check table para_rel;
  ERROR 2013 (HY000): Lost connection to MySQL server during query
  </code></pre>
  
  <p>The table inserts data normally but still cannot select:</p>
  
  <pre><code>mysql&gt; insert into para_rel values(999999,test);
  ERROR 1054 (42S22): Unknown column 'test' in 'field list'
  mysql&gt; insert into para_rel(id,name) values(999999,'test');
  Query OK, 1 row affected (0.00 sec)
  
  mysql&gt; select * from para_rel where id = 999999;
  ERROR 2013 (HY000): Lost connection to MySQL server during query
  </code></pre>
  
  <p>Creating an index on the table also reports an error and fails:</p>
  
  <pre><code>mysql&gt; CREATE INDEX idx_para_rel_id ON para_rel(id);
  ERROR 2013 (HY000): Lost connection to MySQL server during query
  </code></pre>
  
  <p>In general, inserting data is possible, but select, index creation, and check table para_select are not allowed. After reporting the error, wait a while to reconnect to the database before continuing to use the database.</p>
  
  <p>It was later discovered that as soon as the para_rel table was queried, the above connection loss error occurred, and the uptime returned to zero.
  It is found that the phenomenon of increasing the buffer pool is the same.
  From 128M to 2G. After trying the above operations, nothing improved.</p>
  
  <pre><code>mysql&gt; show variables like 'innodb_buffer_pool_size';
  +-------------------------+-----------+
  | Variable_name           | Value     |
  +-------------------------+-----------+
  | innodb_buffer_pool_size | 134217728 |
  +-------------------------+-----------+
  1 row in set (0.01 sec)
  
  
  mysql&gt; SET GLOBAL innodb_buffer_pool_size = 2147483648;
  Query OK, 0 rows affected (0.00 sec)
  
  mysql&gt; show variables like 'innodb_buffer_pool_size';
  +-------------------------+------------+
  | Variable_name           | Value      |
  +-------------------------+------------+
  | innodb_buffer_pool_size | 2147483648 |
  +-------------------------+------------+
  1 row in set (0.00 sec)
  
  mysql&gt; select count(1) from para_rel;
  ERROR 2013 (HY000): Lost connection to MySQL server during query
  </code></pre>
  
  <p>Checking another table created in the same way for the select operation is fine:</p>
  
  <pre><code>mysql&gt; check table para_select;
  +-------------------+-------+----------+----------+
  | Table             | Op    | Msg_type | Msg_text |
  +-------------------+-------+----------+----------+
  | music.para_select | check | status   | OK       |
  +-------------------+-------+----------+----------+
  1 row in set (6.35 sec)
  </code></pre>
  
  <p>And found that the file size of the other select table is larger than para_rel:</p>
  
  <pre><code>[root@freelab music]# ls -lrt
  total 1204232
  -rw-r----- 1 mysql mysql 696254464 Feb 16 02:32 para_select.ibd
  -rw-r----- 1 mysql mysql 536870912 Feb 16 03:05 para_rel.ibd
  [root@freelab music]# pwd
  /mysqldata/music
  </code></pre>
  
  <p>I want to try to export the table and import it to make the table return to normal, but I still get an error:</p>
  
  <pre><code>-bash-4.2$ mysqldump -uroot -p music para_rel &gt; /tmp/music_rel.sql
  Enter password:
  mysqldump: Error 2013: Lost connection to MySQL server during query when dumping table `para_rel` at row: 7790674
  </code></pre>
  
  <p>Each time a similar error occurs, the error log has information similar to the following:</p>
  
  <pre><code>2020-02-16T08:36:09.259538Z mysqld_safe Number of processes running now: 0
  2020-02-16T08:36:09.268539Z mysqld_safe mysqld restarted
  </code></pre>
  
  <p>The repair table command has been used, suggesting that this type of table is not supported.</p>
  
  <pre><code>mysql&gt; repair table para_rel;
  +----------------+--------+----------+---------------------------------------------------------+
  | Table          | Op     | Msg_type | Msg_text                                                |
  +----------------+--------+----------+---------------------------------------------------------+
  | music.para_rel | repair | note     | The storage engine for the table doesn't support repair |
  +----------------+--------+----------+---------------------------------------------------------+
  1 row in set (0.00 sec)
  
  mysql&gt; insert into para_rel(id,name) values(999999,'test');
  Query OK, 1 row affected (0.00 sec)
  
  mysql&gt; select * from para_rel where id = 999999;
  ERROR 2013 (HY000): Lost connection to MySQL server during query
  
  mysql&gt; show create table para_rel;
  +----------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
  | Table    | Create Table                                                                                                                                            |
  +----------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
  | para_rel | CREATE TABLE `para_rel` (
    `id` int DEFAULT NULL,
    `name` varchar(32) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
  +----------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
  1 row in set (0.00 sec)
  
  
  
  </code></pre>
  
  <p>How do I repair this table without using the previously backed up data? </p>