[DB_wait_timeout] Internal Server Error 관련문의
본문
디비 연결 후 timeout이 있어서 끊어 지는거 같습니다.
그누6만 쓰는게 아니라서 wait_timeout 를 글로벌로 변경하기는 뭐해서 찾아보니
sqlalchemy.create_engine("mysql://연결정보", encoding="utf-8", pool_recycle=3600)
이런식으로 수정하라는 말이 있네요...
제가 파이썬 관련해서는 잘모르는지라 질문 드려 봅니다.
그누6에서 저렇게 디비 연결하는 구문이 있는 파일이 어디에 있을까요?
INFO: - "GET /admin/config_form HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/www/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1969, in _exec_single_context
self.dialect.do_execute(
File "/www/venv/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 922, in do_execute
cursor.execute(statement, parameters)
File "/www/venv/lib/python3.10/site-packages/pymysql/cursors.py", line 153, in execute
result = self._query(query)
File "/www/venv/lib/python3.10/site-packages/pymysql/cursors.py", line 322, in _query
conn.query(q)
File "/www/venv/lib/python3.10/site-packages/pymysql/connections.py", line 558, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "/www/venv/lib/python3.10/site-packages/pymysql/connections.py", line 822, in _read_query_result
result.read()
File "/www/venv/lib/python3.10/site-packages/pymysql/connections.py", line 1200, in read
first_packet = self.connection._read_packet()
File "/www/venv/lib/python3.10/site-packages/pymysql/connections.py", line 748, in _read_packet
raise err.OperationalError(
pymysql.err.OperationalError: (2013, 'Lost connection to MySQL server during query')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/www/venv/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 412, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/www/venv/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
return await self.app(scope, receive, send)
File "/www/venv/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in __call__
await super().__call__(scope, receive, send)
File "/www/venv/lib/python3.10/site-packages/starlette/applications.py", line 123, in __call__
await self.middleware_stack(scope, receive, send)
File "/www/venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 186, in __call__
raise exc
File "/www/venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 164, in __call__
await self.app(scope, receive, _send)
File "/www/venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 191, in __call__
response = await self.dispatch_func(request, call_next)
File "/www/core/middleware.py", line 110, in dispatch
return await call_next(request)
File "/www/venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 165, in call_next
raise app_exc
File "/www/venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 151, in coro
await self.app(scope, receive_or_disconnect, send_no_error)
File "/www/venv/lib/python3.10/site-packages/starlette/middleware/sessions.py", line 83, in __call__
await self.app(scope, receive, send_wrapper)
File "/www/venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 191, in __call__
response = await self.dispatch_func(request, call_next)
File "/www/core/middleware.py", line 68, in core_middleware
return await call_next(request)
File "/www/venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 165, in call_next
raise app_exc
File "/www/venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 151, in coro
await self.app(scope, receive_or_disconnect, send_no_error)
File "/www/venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 191, in __call__
response = await self.dispatch_func(request, call_next)
File "/www/main.py", line 223, in main_middleware
response: Response = await call_next(request)
File "/www/venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 165, in call_next
raise app_exc
File "/www/venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 151, in coro
await self.app(scope, receive_or_disconnect, send_no_error)
File "/www/venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/www/venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
raise exc
File "/www/venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
await app(scope, receive, sender)
File "/www/venv/lib/python3.10/site-packages/starlette/routing.py", line 758, in __call__
await self.middleware_stack(scope, receive, send)
File "/www/venv/lib/python3.10/site-packages/starlette/routing.py", line 778, in app
await route.handle(scope, receive, send)
File "/www/venv/lib/python3.10/site-packages/starlette/routing.py", line 299, in handle
await self.app(scope, receive, send)
File "/www/venv/lib/python3.10/site-packages/starlette/routing.py", line 79, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/www/venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
raise exc
File "/www/venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
await app(scope, receive, sender)
File "/www/venv/lib/python3.10/site-packages/starlette/routing.py", line 74, in app
response = await func(request)
File "/www/venv/lib/python3.10/site-packages/fastapi/routing.py", line 278, in app
raw_response = await run_endpoint_function(
File "/www/venv/lib/python3.10/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
return await dependant.call(**values)
File "/www/admin/admin_config.py", line 51, in config_form
return templates.TemplateResponse("config_form.html", context)
File "/www/venv/lib/python3.10/site-packages/starlette/templating.py", line 230, in TemplateResponse
return _TemplateResponse(
File "/www/venv/lib/python3.10/site-packages/starlette/templating.py", line 40, in __init__
content = template.render(context)
File "/www/venv/lib/python3.10/site-packages/jinja2/environment.py", line 1301, in render
self.environment.handle_exception()
File "/www/venv/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
File "admin/templates/basic/config_form.html", line 1, in top-level template code
{% extends "base.html" %}
File "admin/templates/basic/base.html", line 1, in top-level template code
{% extends "base_sub.html" %}
File "admin/templates/basic/base_sub.html", line 31, in top-level template code
{% block body_html %}
File "admin/templates/basic/base.html", line 153, in block 'body_html'
{% block content %}{% endblock content %}
File "admin/templates/basic/config_form.html", line 53, in block 'content'
<td colspan="3">{{ get_member_id_select('cf_admin', 10, config.cf_admin, 'required')|safe }}</td>
File "/www/lib/template_functions.py", line 106, in get_member_id_select
mb_ids = db.scalars(
File "/www/venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 2420, in scalars
return self._execute_internal(
File "/www/venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 2190, in _execute_internal
result: Result[Any] = compile_state_cls.orm_execute_statement(
File "/www/venv/lib/python3.10/site-packages/sqlalchemy/orm/context.py", line 293, in orm_execute_statement
result = conn.execute(
File "/www/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1416, in execute
return meth(
File "/www/venv/lib/python3.10/site-packages/sqlalchemy/sql/elements.py", line 516, in _execute_on_connection
return connection._execute_clauseelement(
File "/www/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1639, in _execute_clauseelement
ret = self._execute_context(
File "/www/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1848, in _execute_context
return self._exec_single_context(
File "/www/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1988, in _exec_single_context
self._handle_dbapi_exception(
File "/www/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2343, in _handle_dbapi_exception
raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
File "/www/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1969, in _exec_single_context
self.dialect.do_execute(
File "/www/venv/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 922, in do_execute
cursor.execute(statement, parameters)
File "/www/venv/lib/python3.10/site-packages/pymysql/cursors.py", line 153, in execute
result = self._query(query)
File "/www/venv/lib/python3.10/site-packages/pymysql/cursors.py", line 322, in _query
conn.query(q)
File "/www/venv/lib/python3.10/site-packages/pymysql/connections.py", line 558, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "/www/venv/lib/python3.10/site-packages/pymysql/connections.py", line 822, in _read_query_result
result.read()
File "/www/venv/lib/python3.10/site-packages/pymysql/connections.py", line 1200, in read
first_packet = self.connection._read_packet()
File "/www/venv/lib/python3.10/site-packages/pymysql/connections.py", line 748, in _read_packet
raise err.OperationalError(
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')
[SQL: SELECT g6_member.mb_id
FROM g6_member
WHERE g6_member.mb_level >= %(mb_level_1)s]
[parameters: {'mb_level_1': 10}]
(Background on this error at: https://sqlalche.me/e/20/e3q8)