MySQL-server-has-gone-away | MySQL server | Runtime Evironment library
kandi X-RAY | MySQL-server-has-gone-away Summary
kandi X-RAY | MySQL-server-has-gone-away Summary
MySQL server has gone away
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Create a CursorWrapper
- Decorator to check if MySQL server has gone away
MySQL-server-has-gone-away Key Features
MySQL-server-has-gone-away Examples and Code Snippets
Community Discussions
Trending Discussions on MySQL-server-has-gone-away
QUESTION
I'm building a Django (ver. 3.0.5) app that uses mysqlclient
(ver. 2.0.3) as the DB backend. Additionally, I've written a Django command that runs a bot written using the python-telegram-bot API, so the mission of this bot is to run indefinitely, as it has to answer to commands anytime.
Problem is that approximately 24hrs. after running the bot (not necessarily being idle all the time), I get a django.db.utils.OperationalError: (2006, 'MySQL server has gone away')
exception after running any command.
I'm absolutely sure the MySQL server has been running all the time and is still running at the time I get this exception. The MySQL server version is 5.7.35
.
My assumption is that some MySQL threads get aged out and get closed, so after reusing them they won't get renewed.
Has anyone bumped into this situation and knows how to solve it?
...ANSWER
Answered 2021-Aug-26 at 11:49This is usually because of server side wait_timeout. Server is closing connection after wait_timeout seconds of inactivity. You should either increase timeout:
QUESTION
I have checked the answers at MySQL error 2006: mysql server has gone away None of them seem to fit my problem.
I am getting the error MySQL server has gone away
frequently.
It is not the connection timeout. The default timeout of 8 hours seems plenty.
I have tried upping the max_allowed_packet
to no avail. This then seemed irrelevant when I began printing out the offending SQL statement which was in my case: SELECT url FROM crawled WHERE frontier = 1 ORDER BY id
. Hardly a large statement which warrants upping max_allowed_packet
.
So, none of the given answers seem to fit my scenario. Any other reasons why this error may occur? Any possible fixes?
...ANSWER
Answered 2020-Jun-09 at 22:28Two common possibilities come to mind:
1) Out Of Memory error. Check syslog for evidence of it.
2) Bug or some other crash in mysqld thread. Check your MySQL error log.
The "server has gone away" almost always means a back end thread crash. And that should leave something obvious in the logs.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install MySQL-server-has-gone-away
You can use MySQL-server-has-gone-away like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page