Transaction handling is buggy - We need a middleware that opens and close transaction on each request.
alexgarel opened this issue · 3 comments
alexgarel commented
What
Today, folksonomy was failing.
Log is as follow (for any request):
nov. 18 11:00:47 folksonomy uvicorn[324]: ERROR: Exception in ASGI application
nov. 18 11:00:47 folksonomy uvicorn[324]: Traceback (most recent call last):
nov. 18 11:00:47 folksonomy uvicorn[324]: File "/home/folksonomy/.local/lib/python3.8/site-packages>
nov. 18 11:00:47 folksonomy uvicorn[324]: result = await app(self.scope, self.receive, self.send)
nov. 18 11:00:47 folksonomy uvicorn[324]: File "/home/folksonomy/.local/lib/python3.8/site-packages>
nov. 18 11:00:47 folksonomy uvicorn[324]: return await self.app(scope, receive, send)
nov. 18 11:00:47 folksonomy uvicorn[324]: File "/home/folksonomy/.local/lib/python3.8/site-packages>
nov. 18 11:00:47 folksonomy uvicorn[324]: await super().__call__(scope, receive, send)
nov. 18 11:00:47 folksonomy uvicorn[324]: File "/home/folksonomy/.local/lib/python3.8/site-packages>
nov. 18 11:00:47 folksonomy uvicorn[324]: await self.middleware_stack(scope, receive, send)
nov. 18 11:00:47 folksonomy uvicorn[324]: File "/home/folksonomy/.local/lib/python3.8/site-packages>
nov. 18 11:00:47 folksonomy uvicorn[324]: raise exc
nov. 18 11:00:47 folksonomy uvicorn[324]: File "/home/folksonomy/.local/lib/python3.8/site-packages>
nov. 18 11:00:47 folksonomy uvicorn[324]: await self.app(scope, receive, _send)
nov. 18 11:00:47 folksonomy uvicorn[324]: File "/home/folksonomy/.local/lib/python3.8/site-packages>
nov. 18 11:00:47 folksonomy uvicorn[324]: raise exc
nov. 18 11:00:47 folksonomy uvicorn[324]: File "/home/folksonomy/.local/lib/python3.8/site-packages>
nov. 18 11:00:47 folksonomy uvicorn[324]: await self.app(scope, receive, sender)
nov. 18 11:00:47 folksonomy uvicorn[324]: File "/home/folksonomy/.local/lib/python3.8/site-packages>
nov. 18 11:00:47 folksonomy uvicorn[324]: await route.handle(scope, receive, send)
nov. 18 11:00:47 folksonomy uvicorn[324]: File "/home/folksonomy/.local/lib/python3.8/site-packages>
nov. 18 11:00:47 folksonomy uvicorn[324]: await self.app(scope, receive, send)
nov. 18 11:00:47 folksonomy uvicorn[324]: File "/home/folksonomy/.local/lib/python3.8/site-packages>
nov. 18 11:00:47 folksonomy uvicorn[324]: response = await func(request)
nov. 18 11:00:47 folksonomy uvicorn[324]: File "/home/folksonomy/.local/lib/python3.8/site-packages>
nov. 18 11:00:47 folksonomy uvicorn[324]: raw_response = await run_endpoint_function(
nov. 18 11:00:47 folksonomy uvicorn[324]: File "/home/folksonomy/.local/lib/python3.8/site-packages>
nov. 18 11:00:47 folksonomy uvicorn[324]: return await dependant.call(**values)
nov. 18 11:00:47 folksonomy uvicorn[324]: File "/home/folksonomy/folksonomy_api/./folksonomy/api.py>
nov. 18 11:00:47 folksonomy uvicorn[324]: timing = await db_exec("""
Steps to reproduce the behavior:
I'm not sure how to reproduce, we should first trigger a hard failure, then all transaction would fail.
Expected behavior
Transaction should be isolated between requests.
The best would be a middleware that opens and close transaction on each request.
You can eventually look how it's done in taxonomy editor.
teolemon commented
Putting a P1 on this @alexgarel , feel free to increase or reduce