A commit on a lost advanced API session answers 200 for work that was rolled back
Los mantenedores suelen responder en 3 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
Línea de trabajo
Start by reading api/sessions.py's load_session_from_context and api/actions.py's commit_raw_connection to understand the session fallback. Examine the oedialect client's engine.py lines 47-71 to see how SQLAlchemy pools reuse connection IDs. The fix must distinguish between a lost session with uncommitted work and an empty transaction after a rollback, likely by tracking recently closed IDs. Test against a real oedialect setup to ensure the fix doesn't break normal pool behavior.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Found while deciding slice 4 of #2492 (WF-20). Its fix is kept out of that work on purpose, because the obvious fix breaks oedialect.
The defect
load_session_from_context (api/sessions.py) looks up the connection_id a client sends. If no session is registered under it, it silently builds a new one under the same id and returns that:
with _LOCK:
sess = _SESSION_CONTEXTS.get(connection_id)
if sess is None:
return SessionContext(connection_id=connection_id, owner=user)
commit_raw_connection (api/actions.py) commits whatever that returns. So a POST /api/v0/advanced/connection/commit for an id whose session is gone commits a fresh, empty transaction and answers 200, while the work the client did on the old session has already been rolled back by Postgres.
A session goes away without the client being told in two ways:
- A server restart or reload. Sessions live only in the memory of the
/api/v0/advancedprocess, so every deploy drops all of them, and each open transaction is rolled back. - The idle sweep. A session idle for longer than
TIME_OUT(30 s) with no open cursor is closed the next time any session is constructed.
A client that did its inserts before either of these and then commits is told its work was saved. That is silent data loss. Committed data is never affected; only work not yet committed.
The same fallback makes any cursor operation on a lost session fail visibly with 400 "Cursor not found", because the rebuilt session has no cursors. The silent case is the commit alone.
Why the obvious fix is wrong
"Refuse an unknown connection_id" would break every oedialect client that uses a SQLAlchemy pool:
oedialect0.1.1 opens once and keeps its id (engine.py:47-71).- SQLAlchemy's client-side pool sends
rollbackon every checkin. SessionContext.rollbackcloses a session that has no open cursor.- The client's next call arrives with the same id, and the fallback rebuilds the session.
That flow is the normal one. Production's live access log on 2026-09-23 showed about one connection/open for every twenty rollback/commit calls. Over 30 days there were 9,159 opens against 136,532 rollbacks and only 563 explicit closes.
What a fix has to get right
- Everything except
commitkeeps working through the fallback. - A
commiton an id whose session is gone must not answer200. The candidate is a refusal saying the connection was lost and its uncommitted work rolled back. - The trap: SQLAlchemy can commit an empty transaction, for example after
engine.begin()with no statement. After a precedingrollbackhas closed the session, that commit would also arrive on an unknown id, and a naive refusal would report a failure where nothing was lost. Distinguishing the two probably means remembering recently closed ids and whether they carried uncommitted work. - Prove it against real
oedialect, as #2491/#2516 was proved against the real engine. A mock cannot show which calls SQLAlchemy's pool actually sends.
The fallback is per process, like everything else in _SESSION_CONTEXTS. The /api/v0/advanced group runs one process, so this is not a multi-process issue, and making it one is out of scope.
Until then
A deploy drops every open session. Deploy in an announced window, and check live traffic on advanced/connection in the access log before restarting.
🤖 Generated with Claude Code
- Lenguaje dominante
- Python
- Estrellas
- 65
- Forks
- 28
- Merge medio
- 4 d 7 h
- PR fusionados (30 d)
- 25
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de OpenEnergyPlatform/oeplatform
-
API bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
OpenEnergyPlatform/oeplatform#2580 ·
Los mantenedores suelen responder en 3 días
-
Redesign the database page to support dataset creationPosiblemente ocupada @bmlancien la tomó hace 4 días. Abiertodata-upload
OpenEnergyPlatform/oeplatform#2762 · 1 comentario · 3 asignados ·
Los mantenedores suelen responder en 3 días
-
Improve navigation links in Core Features and Integrated WorkflowsPosiblemente ocupada @tomi-rli la tomó hace 19 días. AbiertoHomepage
OpenEnergyPlatform/oeplatform#2746 · 1 asignado ·
Los mantenedores suelen responder en 3 días
-
Enhance the new OEP homepagePosiblemente ocupada @jh-RLI la tomó hace 19 días. AbiertoHomepage
OpenEnergyPlatform/oeplatform#2745 · 2 asignados ·
Los mantenedores suelen responder en 3 días
-
Display child nodes in the OEO Viewer Graph ViewPosiblemente ocupada @jh-RLI la tomó hace 23 días. Abiertooeo viewer
OpenEnergyPlatform/oeplatform#2739 · 1 asignado ·
Los mantenedores suelen responder en 3 días
Todos los issues de OpenEnergyPlatform/oeplatform
Issues similares
-
needs-triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
flashinfer-ai/flashinfer#9803 ·
Los mantenedores suelen responder en 1 día
-
bug frontend good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
oscarbol09/thesisforge#61 ·
-
api bug performance
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
oscarbol09/audiobard#159 ·
-
area:web p2 product:business triage:active type:bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 89/100
cuadrao-ai/argus#2328 ·
Los mantenedores suelen responder en 1 día
-
bug frontend good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
nikhilb2/simple_invoicing#907 ·