ERROR 2013 (HY000): Lost connection to MySQL server during query

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: ERROR 2013 (HY000): Lost connection to MySQL server during query

| username: 答辩潮人

Error: ERROR 2013 (HY000): Lost connection to MySQL server during query
Configuration: set max_execution_time = 0; set tidb_mem_quota_query = 0;
tidb.log error: [expensivequery.go:178] [expensive_query] [cost_time=60.058973402s]
WeChat Screenshot_20230314140924
WeChat Screenshot_20230314140939
Are there any other parameters that need to be adjusted? The machine still has 60% of memory unused.

| username: jackerzhou | Original post link

Check if the client has set a timeout.

| username: liuis | Original post link

Try setting the database read timeout to a longer duration.

| username: TI表弟 | Original post link

Check this document for specific parameter descriptions: set global tidb_mem_quota_query. You can modify it by using set global var_name = value.

| username: 答辩潮人 | Original post link

There is no timeout issue with command line operations.

| username: 答辩潮人 | Original post link

The version only supports session, and the session is already set to unlimited in the picture.

| username: WalterWj | Original post link

Is there a restart or a panic match in the logs for TiDB?

| username: TI表弟 | Original post link

The image you provided is not visible. Please provide the text you need translated.

| username: TI表弟 | Original post link

You’re upgrading from version 4 to 6.5.0, right?

| username: TI表弟 | Original post link

The image is not visible. Please provide the text you need translated.

| username: 答辩潮人 | Original post link

There are no panic characters matched in the tidb.log.

| username: 答辩潮人 | Original post link

I know, if it’s not a clear bug, who would want to touch the production environment?

| username: 答辩潮人 | Original post link

net_read_timeout? Can you provide a detailed parameter?

| username: TI表弟 | Original post link

Did TiDB restart during this period?

| username: liuis | Original post link

Judging by this performance, it seems like the read timeout is too short. Check if there are any logs, otherwise, it’s hard to know where to start.

| username: 答辩潮人 | Original post link

Are there any keywords?

| username: 答辩潮人 | Original post link

Where can I match the keywords?

| username: 我是咖啡哥 | Original post link

It seems to be an OOM issue. Check the startup times of each component.

| username: liuis | Original post link

How does a lost connection relate to OOM (Out of Memory)?

| username: 我是咖啡哥 | Original post link

I remember encountering this issue. When the TiDB server OOM restarts, the client will report this error.