rest-framework icon indicating copy to clipboard operation
rest-framework copied to clipboard

[17.0] fastapi: Production outages: RuntimeError

Open JochenVanSeveren opened this issue 10 months ago • 2 comments

Module

fastapi

Describe the bug

2025-03-27 11:15:26,319 13776 ERROR my-odoo-instance odoo.http: Exception during request handling. 
Traceback (most recent call last):
  File "/home/odoo/src/odoo/odoo/tools/cache.py", line 99, in lookup
    r = d[key]
  File "<decorator-gen-5>", line 2, in __getitem__
  File "/home/odoo/src/odoo/odoo/tools/func.py", line 87, in locked
    return func(inst, *args, **kwargs)
  File "/home/odoo/src/odoo/odoo/tools/lru.py", line 34, in __getitem__
    a = self.d[obj]
KeyError: ('fastapi.endpoint', <function FastapiEndpoint.get_app at 0x7fbe3e2e2710>, '/app')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/odoo/src/odoo/odoo/http.py", line 2213, in __call__
    response = request._serve_db()
  File "/home/odoo/src/odoo/odoo/http.py", line 1788, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
  File "/home/odoo/src/odoo/odoo/service/model.py", line 152, in retrying
    result = func()
  File "/home/odoo/src/odoo/odoo/http.py", line 1816, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
  File "/home/odoo/src/user/OCA/rest-framework/extendable_fastapi/fastapi_dispatcher.py", line 19, in dispatch
    return super().dispatch(endpoint, args)
  File "/home/odoo/src/user/OCA/rest-framework/fastapi/fastapi_dispatcher.py", line 28, in dispatch
    app = fastapi_endpoint.get_app(root_path)
  File "<decorator-gen-126>", line 2, in get_app
  File "/home/odoo/src/odoo/odoo/tools/cache.py", line 104, in lookup
    value = d[key] = self.method(*args, **kwargs)
  File "/home/odoo/src/user/OCA/rest-framework/fastapi/models/fastapi_endpoint.py", line 216, in get_app
    return ASGIMiddleware(app)
  File "/home/odoo/.local/lib/python3.10/site-packages/a2wsgi/asgi.py", line 131, in __init__
    loop_threading.start()
  File "/usr/lib/python3.10/threading.py", line 935, in start
    _start_new_thread(self._bootstrap, ())
RuntimeError: can't start new thread

To Reproduce

This occured a couple of times already in production and the error repeats itself untill the server is restarted.

Additional context Let me know if additional context is needed.

JochenVanSeveren avatar Mar 27 '25 14:03 JochenVanSeveren

Maybe this is #484

sbidoul avatar Mar 27 '25 18:03 sbidoul

Thank you Stéphane. Seems it could be the case. It's quite hard to tell any resource induced outages the Odoo.sh monitoring tab. Then again, it's not that accurate of a tool.

How can I help merge #486 into 17.0? My knowledge doesn't go further then basic threads. Not afraid to give it a shot though.

JochenVanSeveren avatar Mar 27 '25 22:03 JochenVanSeveren

There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.

github-actions[bot] avatar Sep 28 '25 12:09 github-actions[bot]