简体   繁体   中英

Lost connection to MySQL server during query when creating index

I am creating a fulltext index on a large table (using command line), so I expect it to take a very long time. Unfortunately every time I get this error after some time (about 1 hour):

mysql> CREATE FULLTEXT INDEX ix_fulltext_catalog ON catalog(catalog_content);
ERROR 2013 (HY000): Lost connection to MySQL server during query

Then when I try to run any command, it just reconnects:

mysql> show variables like 'connect_timeout';
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    8

I tried to set many variables to higher values, but it didn't help. These are my values:

| Variable_name                                 | Value              |
+-----------------------------------------------+--------------------+
| connect_timeout                               | 172800             |
| disconnect_on_expired_password                | ON                 |
| init_connect                                  |                    |
| max_connect_errors                            | 100                |
| max_connections                               | 151                |
| max_user_connections                          | 0                  |
| mysqlx_connect_timeout                        | 30                 |
| mysqlx_max_connections                        | 100                |
| performance_schema_session_connect_attrs_size | 512                |
| connect_timeout                               | 172800             |
| delayed_insert_timeout                        | 300                |
| have_statement_timeout                        | YES                |
| innodb_flush_log_at_timeout                   | 1                  |
| innodb_lock_wait_timeout                      | 50                 |
| innodb_rollback_on_timeout                    | OFF                |
| interactive_timeout                           | 172800             |
| lock_wait_timeout                             | 31536000           |
| mysqlx_connect_timeout                        | 30                 |
| mysqlx_idle_worker_thread_timeout             | 60                 |
| mysqlx_interactive_timeout                    | 28800              |
| mysqlx_port_open_timeout                      | 0                  |
| mysqlx_read_timeout                           | 30                 |
| mysqlx_wait_timeout                           | 28800              |
| mysqlx_write_timeout                          | 60                 |
| net_read_timeout                              | 30                 |
| net_write_timeout                             | 60                 |
| rpl_stop_slave_timeout                        | 31536000           |
| slave_net_timeout                             | 60                 |
| wait_timeout                                  | 172800             |
+-----------------------------------------------+--------------------+

I also checked the error.log file, but there are no errors at all, It seems like the server just 'falls asleep' after 1 hour. like if nothing was happening in the background? Can somebody help please?

EDIT: as @danblack suggested, I tried to use dmesg and it shows I'm running out of memory.

Out of memory: Killed process 489295 (mysqld) total-vm:12674556kB, anon-rss:10791368kB, 
file-rss:0kB, shmem-rss:0kB, UID:126 pgtables:21724kB oom_score_adj:0

Due to OOM:

option 1:

Reduce innodb_buffer_pool_size (online) during the adding the index.

option 2:

Use another full text search implementation and not MySQL. Dedicated applications like Solr, Sphinx-search etc for text search do intuitive search a lot better.

(disclaimer I've only used versions earlier than MySQL-8.0).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM