This topic describes how to handle ERROR 2013, where the connection to the server is disconnected in the MySQL mode of OceanBase Database.
Symptom
The session has been idle for a long period of time after the connection to the database is established. In this case, when you execute an SQL statement for viewing data in the ordr table, an error is reported, indicating that the connection is disconnected.
obclient [test]> SELECT * FROM ordr;
ERROR 2013 (HY000): Lost connection to MySQL server during query
Possible causes
In OceanBase Database, when the idle time of a session exceeds the specified threshold, the system closes the current connection and reports ERROR 2013 for the next operation.
Troubleshooting procedure
Take the following steps to view and modify the values of session-related variables. The following variable setting method takes effect only for the current session. To make the settings permanent, use the SET GLOBAL syntax to configure these variables, and then restart the session for the settings to take effect.
Reconnect to the corresponding MySQL tenant.
View time-related variables.
obclient [test]> SHOW VARIABLES LIKE '%time%'; +---------------------------------+------------------+ | Variable_name | Value | +---------------------------------+------------------+ | connect_timeout | 10 | | default_password_lifetime | 0 | | error_on_overlap_time | OFF | | explicit_defaults_for_timestamp | ON | | interactive_timeout | 10000 | | lock_wait_timeout | 31536000 | | long_query_time | 10 | | max_execution_time | 0 | | net_read_timeout | 30 | | net_write_timeout | 60 | | ob_pl_block_timeout | 3216672000000000 | | ob_query_timeout | 10000000 | | ob_trx_idle_timeout | 86400000000 | | ob_trx_lock_timeout | -1 | | ob_trx_timeout | 86400000000 | | system_time_zone | +08:00 | | timestamp | 0 | | time_format | %H:%i:%s | | time_zone | +8:00 | | wait_timeout | 10000 | +---------------------------------+------------------+ 20 rows in setSet the value of the
wait_timeoutvariable to28800.obclient [test]> SET wait_timeout = 28800; Query OK, 0 rows affectedSet the value of the
interactive_timeoutvariable to28800.obclient [test]> SET interactive_timeout = 28800; Query OK, 0 rows affectedView the
ordrtable again. The table can be queried normally.obclient [test]> SELECT * FROM ordr; +----+---------------------+---------------------+ | id | gmt_create | gmt_modified | +----+---------------------+---------------------+ | 1 | 2022-03-16 14:23:10 | 2022-03-16 14:23:10 | | 2 | 2022-03-16 14:23:10 | 2022-03-16 14:23:10 | | 3 | 2022-03-16 14:23:10 | 2022-03-16 14:23:10 | +----+---------------------+---------------------+ 3 rows in set
References
For more information about the
wait_timeoutparameter, see wait_timeout.For more information about the
interactive_timeoutparameter, see interactive_timeout.