Вопрос «Потеряно соединение с сервером MySQL во время запроса». Некоторые говорят, что это был просто запрос к слишком большой таблице, но кроме этой ситуации.
Эта ошибка просто делает SQL как «выбрать 1», и тогда мы обнаруживаем ошибку:
(pymysql.err.OperationalError) (2013, «Потерянное соединение с сервером MySQL во время запроса») [SQL: u'SELECT 1 '].
Я нашел код pymysql и журнал ошибок.
Код, вызвавший исключение:
в файле /usr/lib/python2.7/site-packages/pymysql/connections.py.
def _read_bytes(self, num_bytes):
self._sock.settimeout(self._read_timeout)
while True:
try:
data = self._rfile.read(num_bytes)
break
except (IOError, OSError) as e:
if e.errno == errno.EINTR:
continue
self._force_close()
raise err.OperationalError(
CR.CR_SERVER_LOST,
"Lost connection to MySQL server during query (%s)" % (e,))
if len(data) < num_bytes: #wops here
self._force_close()
raise err.OperationalError(
CR.CR_SERVER_LOST, "Lost connection to MySQL server during query")
return data
Журнал ошибок приведен ниже:
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event File "/usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/engines.py", line 80, in _connect_ping_listener
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event connection.scalar(select([1]))
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 877, in scalar
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event return self.execute(object, *multiparams, **params).scalar()
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 945, in execute
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event return meth(self, multiparams, params)
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event File "/usr/lib64/python2.7/site-packages/sqlalchemy/sql/elements.py", line 263, in _execute_on_connection
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event return connection._execute_clauseelement(self, multiparams, params)
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1053, in _execute_clauseelement
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event compiled_sql, distilled_params
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1189, in _execute_context
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event context)
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1398, in _handle_dbapi_exception
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event util.raise_from_cause(newraise, exc_info)
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event File "/usr/lib64/python2.7/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event reraise(type(exception), exception, tb=exc_tb, cause=cause)
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event context)
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event cursor.execute(statement, parameters)
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event File "/usr/lib/python2.7/site-packages/pymysql/cursors.py", line 166, in execute
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event result = self._query(query)
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event File "/usr/lib/python2.7/site-packages/pymysql/cursors.py", line 322, in _query
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event conn.query(q)
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 856, in query
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event self._affected_rows = self._read_query_result(unbuffered=unbuffered)
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 1057, in _read_query_result
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event result.read()
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 1340, in read
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event first_packet = self.connection._read_packet()
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 987, in _read_packet
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event packet_header = self._read_bytes(4)
2018-07-06 04:43:19.171 4674 ERROR aodh.evaluator.event File "/usr