在查询过程中烧瓶失去与mysql服务器的连接/读取通信数据包时出错

时间:2019-05-19 19:58:55

标签: python mysql sqlalchemy flask-sqlalchemy

我在flask / SQLalchemy / MySQL上启动了我的第一个站点。

当我进行自我测试时,我从未遇到任何错误,但是现在我注意到从db加载页面时崩溃(我打印出看起来不错的参数)。

[Sun May 19 19:10:05.904181 2019] [wsgi:error] [pid 5713:tid 139891566540544] 
[remote 35.230.11.17:46556] ERROR:flask.app:Exception on /blog/welcome/ [HEAD]
[Sun May 19 19:10:05.904198 2019] [wsgi:error] [pid 5713:tid 139891566540544] [remote 35.230.11.17:46556] Traceback (most recent call last):
[Sun May 19 19:10:05.904201 2019] [wsgi:error] [pid 5713:tid 139891566540544] [remote 35.230.11.17:46556]   File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/sqlalchemy/engine/base.py"$
[Sun May 19 19:10:05.904205 2019] [wsgi:error] [pid 5713:tid 139891566540544] [remote 35.230.11.17:46556]     cursor, statement, parameters, context
[Sun May 19 19:10:05.904208 2019] [wsgi:error] [pid 5713:tid 139891566540544] [remote 35.230.11.17:46556]   File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/sqlalchemy/engine/default.$
[Sun May 19 19:10:05.904211 2019] [wsgi:error] [pid 5713:tid 139891566540544] [remote 35.230.11.17:46556]     cursor.execute(statement, parameters)
[Sun May 19 19:10:05.904214 2019] [wsgi:error] [pid 5713:tid 139891566540544] [remote 35.230.11.17:46556]   File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/MySQLdb/cursors.py", line $
[Sun May 19 19:10:05.904217 2019] [wsgi:error] [pid 5713:tid 139891566540544] [remote 35.230.11.17:46556]     res = self._query(query)
[Sun May 19 19:10:05.904219 2019] [wsgi:error] [pid 5713:tid 139891566540544] [remote 35.230.11.17:46556]   File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/MySQLdb/cursors.py", line $
[Sun May 19 19:10:05.904222 2019] [wsgi:error] [pid 5713:tid 139891566540544] [remote 35.230.11.17:46556]     db.query(q)
[Sun May 19 19:10:05.904225 2019] [wsgi:error] [pid 5713:tid 139891566540544] [remote 35.230.11.17:46556]   File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/MySQLdb/connections.py", l$
[Sun May 19 19:10:05.904228 2019] [wsgi:error] [pid 5713:tid 139891566540544] [remote 35.230.11.17:46556]     _mysql.connection.query(self, query)
[Sun May 19 19:10:05.904231 2019] [wsgi:error] [pid 5713:tid 139891566540544] [remote 35.230.11.17:46556] MySQLdb._exceptions.OperationalError: (2013, 'Lost connection to MySQL server during $
[Sun May 19 19:10:05.904234 2019] [wsgi:error] [pid 5713:tid 139891566540544] [remote 35.230.11.17:46556]
[Sun May 19 19:10:05.904237 2019] [wsgi:error] [pid 5713:tid 139891566540544] [remote 35.230.11.17:46556] The above exception was the direct cause of the following exception:

...some more stuff... 

[Sun May 19 19:10:05.904383 2019] [wsgi:error] [pid 5713:tid 139891566540544] [remote 35.230.11.17:46556] sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (2013, 'Lost $
[Sun May 19 19:10:05.904387 2019] [wsgi:error] [pid 5713:tid 139891566540544] [remote 35.230.11.17:46556] [SQL: SELECT entries.id AS entries_id, entries.title AS entries_title, entries.slug A$
[Sun May 19 19:10:05.904390 2019] [wsgi:error] [pid 5713:tid 139891566540544] [remote 35.230.11.17:46556] FROM entries
[Sun May 19 19:10:05.904392 2019] [wsgi:error] [pid 5713:tid 139891566540544] [remote 35.230.11.17:46556] WHERE entries.slug = %s]
[Sun May 19 19:10:05.904394 2019] [wsgi:error] [pid 5713:tid 139891566540544] [remote 35.230.11.17:46556] [parameters: ('welcome',)]
[Sun May 19 19:10:05.904399 2019] [wsgi:error] [pid 5713:tid 139891566540544] [remote 35.230.11.17:46556] (Background on this error at: http://sqlalche.me/e/e3q8)

如果我查看MySQL日志,则会发现:

2019-05-19T19:10:05.899896Z 28 [Note] Aborted connection 28 to db: 'test10' user: 'root' host: 'localhost' (Got an error reading communication packets)

我添加了

SQLALCHEMY_POOL_RECYCLE = 299
SQLALCHEMY_POOL_TIMEOUT = 20

到我的烧瓶中,然后重新启动Apache,但这没有帮助。

从我的数据库中读取的内容是一个简单的博客文章:

enter image description here

我该怎么做才能更好地了解出了什么问题?还是有潜在的快速修复方法?

谢谢!

0 个答案:

没有答案