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

Related images taking too long to respond causes SystemExit #1191

Closed
AetherUnbound opened this issue Apr 13, 2023 · 1 comment
Closed

Related images taking too long to respond causes SystemExit #1191

AetherUnbound opened this issue Apr 13, 2023 · 1 comment
Assignees
Labels
💻 aspect: code Concerns the software code in the repository 🛠 goal: fix Bug fix 🟧 priority: high Stalls work on the project or its dependents 🧱 stack: api Related to the Django API 🐛 tooling: sentry Sentry issue

Comments

@AetherUnbound
Copy link
Contributor

Sentry link

https://openverse.sentry.io/share/issue/b4898535c2184d179c3ae2642f6ea429/

Description

It looks like the images/{identifier}/related page will occasionally take too long to load for certain images, and will cause both a gateway timeout for the user and an uncaught SystemExit exception. Here's the stacktrace (I kept the entire thing in case the redundant lines are indicative of something):

SystemExit: 1
  File "django/core/handlers/wsgi.py", line 131, in __call__
    response = self.get_response(request)
  File "django/core/handlers/base.py", line 140, in get_response
    response = self._middleware_chain(request)
  File "django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
  File "django/utils/deprecation.py", line 136, in __call__
    response = response or self.get_response(request)
  File "django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
  File "django/utils/deprecation.py", line 136, in __call__
    response = response or self.get_response(request)
  File "django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
  File "django/utils/deprecation.py", line 136, in __call__
    response = response or self.get_response(request)
  File "django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
  File "django/utils/deprecation.py", line 136, in __call__
    response = response or self.get_response(request)
  File "django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
  File "django/utils/deprecation.py", line 136, in __call__
    response = response or self.get_response(request)
  File "django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
  File "django/utils/deprecation.py", line 136, in __call__
    response = response or self.get_response(request)
  File "django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
  File "django/utils/deprecation.py", line 136, in __call__
    response = response or self.get_response(request)
  File "django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
  File "django/utils/deprecation.py", line 136, in __call__
    response = response or self.get_response(request)
  File "django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
  File "django/utils/deprecation.py", line 136, in __call__
    response = response or self.get_response(request)
  File "django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
  File "oauth2_provider/middleware.py", line 36, in __call__
    response = self.get_response(request)
  File "django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
  File "django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "django/views/decorators/csrf.py", line 55, in wrapped_view
    return view_func(*args, **kwargs)
  File "rest_framework/viewsets.py", line 125, in view
    return self.dispatch(request, *args, **kwargs)
  File "rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "django/utils/decorators.py", line 46, in _wrapper
    return bound_method(*args, **kwargs)
  File "catalog/api/views/media_views.py", line 132, in related
    results, num_results = search_controller.related_media(
  File "catalog/api/controllers/search_controller.py", line 483, in related_media
    results = _post_process_results(
  File "catalog/api/controllers/search_controller.py", line 216, in _post_process_results
    return _post_process_results(
  File "catalog/api/controllers/search_controller.py", line 216, in _post_process_results
    return _post_process_results(
  File "catalog/api/controllers/search_controller.py", line 216, in _post_process_results
    return _post_process_results(
  File "catalog/api/controllers/search_controller.py", line 216, in _post_process_results
    return _post_process_results(
  File "catalog/api/controllers/search_controller.py", line 216, in _post_process_results
    return _post_process_results(
  File "catalog/api/controllers/search_controller.py", line 216, in _post_process_results
    return _post_process_results(
  File "catalog/api/controllers/search_controller.py", line 216, in _post_process_results
    return _post_process_results(
  File "catalog/api/controllers/search_controller.py", line 216, in _post_process_results
    return _post_process_results(
  File "catalog/api/controllers/search_controller.py", line 216, in _post_process_results
    return _post_process_results(
  File "catalog/api/controllers/search_controller.py", line 216, in _post_process_results
    return _post_process_results(
  File "catalog/api/controllers/search_controller.py", line 216, in _post_process_results
    return _post_process_results(
  File "catalog/api/controllers/search_controller.py", line 216, in _post_process_results
    return _post_process_results(
  File "catalog/api/controllers/search_controller.py", line 214, in _post_process_results
    search_response = s.execute()
  File "elasticsearch_dsl/search.py", line 723, in execute
    self, es.search(index=self._index, **params)
  File "elasticsearch/client/utils.py", line 347, in _wrapped
    return func(*args, params=params, headers=headers, **kwargs)
  File "elasticsearch/client/__init__.py", line 1821, in search
    return self.transport.perform_request(
  File "elasticsearch/transport.py", line 427, in perform_request
    status, headers_response, data = connection.perform_request(
  File "elasticsearch/connection/http_requests.py", line 166, in perform_request
    response = self.session.send(prepared_request, **send_kwargs)
  File "requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "requests/adapters.py", line 489, in send
    resp = conn.urlopen(
  File "urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "urllib3/connectionpool.py", line 449, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
    # Permission is hereby granted, free of charge, to any person obtaining a copy
  File "urllib3/connectionpool.py", line 444, in _make_request
    httplib_response = conn.getresponse()
  File "http/client.py", line 1375, in getresponse
    response.begin()
  File "http/client.py", line 318, in begin
    version, status, reason = self._read_status()
  File "http/client.py", line 279, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "socket.py", line 705, in readinto
    return self._sock.recv_into(b)
  File "gevent/_socketcommon.py", line 693, in recv_into
    self._wait(self._read_event)
  File "src/gevent/_hub_primitives.py", line 317, in gevent._gevent_c_hub_primitives.wait_on_socket
  File "src/gevent/_hub_primitives.py", line 322, in gevent._gevent_c_hub_primitives.wait_on_socket
  File "src/gevent/_hub_primitives.py", line 313, in gevent._gevent_c_hub_primitives._primitive_wait
  File "src/gevent/_hub_primitives.py", line 314, in gevent._gevent_c_hub_primitives._primitive_wait
  File "src/gevent/_hub_primitives.py", line 46, in gevent._gevent_c_hub_primitives.WaitOperationsGreenlet.wait
  File "src/gevent/_hub_primitives.py", line 46, in gevent._gevent_c_hub_primitives.WaitOperationsGreenlet.wait
  File "src/gevent/_hub_primitives.py", line 55, in gevent._gevent_c_hub_primitives.WaitOperationsGreenlet.wait
  File "src/gevent/_waiter.py", line 154, in gevent._gevent_c_waiter.Waiter.get
  File "src/gevent/_greenlet_primitives.py", line 61, in gevent._gevent_c_greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/_greenlet_primitives.py", line 61, in gevent._gevent_c_greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/_greenlet_primitives.py", line 65, in gevent._gevent_c_greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/_gevent_c_greenlet_primitives.pxd", line 35, in gevent._gevent_c_greenlet_primitives._greenlet_switch
  File "gunicorn/workers/base.py", line 203, in handle_abort
    sys.exit(1)

Reproduction

This is, fortunately, highly reproducible with the following URL: https://api.openverse.engineering/v1/images/520a3049-afaa-47e7-b060-7928a3b04df9/related/

I wonder if this is perhaps because all of the stored, related images are dead links and so the API is just iterating again and again to try and find some images.

@AetherUnbound AetherUnbound added 🐛 tooling: sentry Sentry issue 💻 aspect: code Concerns the software code in the repository 🛠 goal: fix Bug fix 🟧 priority: high Stalls work on the project or its dependents 🧱 stack: api Related to the Django API labels Apr 13, 2023
@sarayourfriend sarayourfriend self-assigned this Jun 21, 2023
@sarayourfriend
Copy link
Contributor

This will be fixed by #2415

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💻 aspect: code Concerns the software code in the repository 🛠 goal: fix Bug fix 🟧 priority: high Stalls work on the project or its dependents 🧱 stack: api Related to the Django API 🐛 tooling: sentry Sentry issue
Projects
Archived in project
Development

No branches or pull requests

2 participants