Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Fix Too many open files Exception #86

Open
samderanova opened this issue Jan 29, 2023 · 2 comments
Open

Fix Too many open files Exception #86

samderanova opened this issue Jan 29, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@samderanova
Copy link
Contributor

  • Serverless function threw the above OSError
  • Backend route involved is /api/user/me
@taesungh taesungh added the bug Something isn't working label Jan 29, 2023
@taesungh
Copy link
Member

taesungh commented Jan 29, 2023

Temporarily resolved by manually redeploying to restart Lambda. During time of incident, all API routes were down. This happened once before on January 17th but went unnoticed. Digging through logs, found two different tracebacks, both raising OSError.

[ERROR] OSError: [Errno 24] Too many open files
Traceback (most recent call last):
  File "/var/task/vc__handler__python.py", line 297, in vc_handler
    response = asgi_cycle(__vc_module.app, body)
  File "/var/task/vc__handler__python.py", line 201, in __call__
    loop = asyncio.new_event_loop()
  File "/var/lang/lib/python3.9/asyncio/events.py", line 761, in new_event_loop
    return get_event_loop_policy().new_event_loop()
  File "/var/lang/lib/python3.9/asyncio/events.py", line 659, in new_event_loop
    return self._loop_factory()
  File "/var/lang/lib/python3.9/asyncio/unix_events.py", line 54, in __init__
    super().__init__(selector)
  File "/var/lang/lib/python3.9/asyncio/selector_events.py", line 56, in __init__
    self._make_self_pipe()
  File "/var/lang/lib/python3.9/asyncio/selector_events.py", line 103, in _make_self_pipe
    self._ssock, self._csock = socket.socketpair()
  File "/var/lang/lib/python3.9/socket.py", line 606, in socketpair
    a, b = _socket.socketpair(family, type, proto)

[ERROR] OSError: [Errno 24] Too many open files
Traceback (most recent call last):
  File "/var/task/vc__handler__python.py", line 297, in vc_handler
    response = asgi_cycle(__vc_module.app, body)
  File "/var/task/vc__handler__python.py", line 201, in __call__
    loop = asyncio.new_event_loop()
  File "/var/lang/lib/python3.9/asyncio/events.py", line 761, in new_event_loop
    return get_event_loop_policy().new_event_loop()
  File "/var/lang/lib/python3.9/asyncio/events.py", line 659, in new_event_loop
    return self._loop_factory()
  File "/var/lang/lib/python3.9/asyncio/unix_events.py", line 54, in __init__
    super().__init__(selector)
  File "/var/lang/lib/python3.9/asyncio/selector_events.py", line 53, in __init__
    selector = selectors.DefaultSelector()
  File "/var/lang/lib/python3.9/selectors.py", line 350, in __init__

where vc__handler__python.py refers to Vercel's Python runtime handler.

In some instances, there were also messages about

AttributeError: '_UnixSelectorEventLoop' object has no attribute '_ssock'

@samderanova
Copy link
Contributor Author

Would we have to set the event loop manually? https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.SelectorEventLoop

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants