django報錯 django.db.utils.OperationalError: (2006, 'MySQL server has gone away')

发布时间 2023-05-17 16:06:23作者: jasmine456

Internal Server Error: /lotus/sectors/getAll/129/
Traceback (most recent call last):
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/django/db/backends/mysql/base.py", line 73, in execute
return self.cursor.execute(query, args)
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/MySQLdb/cursors.py", line 319, in _query
db.query(q)
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/MySQLdb/connections.py", line 254, in query
_mysql.connection.query(self, query)
MySQLdb.OperationalError: (2006, 'MySQL server has gone away')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, callback_args, **callback_kwargs)
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(
args, **kwargs)
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/rest_framework/viewsets.py", line 125, in view
return self.dispatch(request, *args, **kwargs)
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/rest_framework/views.py", line 509, in dispatch
response = self.handle_exception(exc)
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/rest_framework/views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
raise exc
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/rest_framework/views.py", line 506, in dispatch
response = handler(request, args, **kwargs)
File "/root/python-src/lotus_mammoth_backend/lotusMgr/views.py", line 76, in get_all
runner.sector_updtate_execute()
File "/root/python-src/lotus_mammoth_backend/lotusMgr/runner/getSshCommand.py", line 288, in sector_updtate_execute
Sector.objects.bulk_update(sectorList,
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(
args, kwargs)
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/django/db/models/query.py", line 568, in bulk_update
self.filter(pk__in=pks).update(
update_kwargs)
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/django/db/models/query.py", line 783, in update
rows = query.get_compiler(self.db).execute_sql(CURSOR)
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1535, in execute_sql
cursor = super().execute_sql(result_type)
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1169, in execute_sql
cursor.execute(sql, params)
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/django/db/backends/utils.py", line 98, in execute
return super().execute(sql, params)
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/django/db/backends/utils.py", line 66, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/django/db/backends/utils.py", line 79, in _execute
with self.db.wrap_database_errors:
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/django/db/utils.py", line 90, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/django/db/backends/mysql/base.py", line 73, in execute
return self.cursor.execute(query, args)
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/MySQLdb/cursors.py", line 319, in _query
db.query(q)
File "/root/.cache/pypoetry/virtualenvs/lotus-mammoth-backend-BC7INJe9-py3.10/lib/python3.10/site-packages/MySQLdb/connections.py", line 254, in query
_mysql.connection.query(self, query)
django.db.utils.OperationalError: (2006, 'MySQL server has gone away')