Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] /apps/subject/models.py:170 traceback 출력으로 인한 성능저하 #992

Open
DoyunShin opened this issue Jan 8, 2024 · 0 comments · May be fixed by #995
Open

[BUG] /apps/subject/models.py:170 traceback 출력으로 인한 성능저하 #992

DoyunShin opened this issue Jan 8, 2024 · 0 comments · May be fixed by #995
Assignees
Labels

Comments

@DoyunShin
Copy link
Member

설명

traceback.print_stack() 으로 인해 파이썬 내장의 stdout이 발생하면서 성능이 저하됨.
traceback을 logger에 붙인 후, logger를 prompt_toolkit으로 붙여서 성능개선하거나, traceback.print_stack()구문에 DEBUG 파라메터를 붙여서 디버깅 용도로만 사용할 수 있도록 변경하는것을 추천함.

재현 순서

Wheel 권한이 있는 사람은 OTL Node 1 (또는 다른곳도 동일)에 들어가서 docker logs otlplus-back 을 실행하면 초당 30~40줄의 기록이 쌓이는것을 확인할 수 있음.

예상하는 올바른 결과

WARNING로그만 뜨는것이 올바르다고 생각됨.

에러 로그

스크린샷

WARNING: You are serializing DELETED lecture: 전자회로(EE304 B). Please check your query
  File "/usr/local/lib/python3.8/site-packages/gevent/baseserver.py", line 34, in _handle_and_close_when_done
    return handle(*args_tuple)
  File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/ggevent.py", line 123, in handle
    super().handle(listener, client, addr)
  File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/base_async.py", line 55, in handle
    self.handle_request(listener_name, req, client, addr)
  File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/ggevent.py", line 127, in handle_request
    super().handle_request(listener_name, req, sock, addr)
  File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/base_async.py", line 108, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/wsgi.py", line 141, in __call__
    response = self.get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 75, in get_response
    response = self._middleware_chain(request)
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/utils/deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/utils/deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/utils/deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/utils/deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/utils/deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/utils/deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/utils/deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/utils/deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/utils/deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.8/site-packages/django/views/generic/base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/django/views/generic/base.py", line 97, in dispatch
    return handler(request, *args, **kwargs)
  File "/var/www/otlplus/apps/subject/views.py", line 116, in get
    result = [review.to_json(user=request.user) for review in reviews]
  File "/var/www/otlplus/apps/subject/views.py", line 116, in <listcomp>
    result = [review.to_json(user=request.user) for review in reviews]
  File "/var/www/otlplus/apps/review/models.py", line 65, in to_json
    "lecture": self.lecture.to_json(nested=True),
  File "/var/www/otlplus/apps/subject/models.py", line 170, in to_json
    traceback.print_stack()

개발 환경

AWS Prod 환경

테스트 환경

AWS Prod 환경

끝.

@DoyunShin DoyunShin added the bug label Jan 8, 2024
@yumincho yumincho linked a pull request Mar 2, 2024 that will close this issue
@yumincho yumincho linked a pull request Mar 2, 2024 that will close this issue
@yumincho yumincho assigned yumincho and unassigned sboh1214 Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants