A commit on a lost advanced API session answers 200 for work that was rolled back
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Python
- スター
- 65
- フォーク
- 28
- 平均マージ
- 4日 7時間
- マージ済み PR(30日)
- 25
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
OpenEnergyPlatform/oeplatform のほかの issue
-
API bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
OpenEnergyPlatform/oeplatform#2580 ·
メンテナーはふだん 3 日以内に返信
-
Redesign the database page to support dataset creation対応中かも @bmlancien が 4 日前に担当しました。 オープンdata-upload
OpenEnergyPlatform/oeplatform#2762 · コメント 1 件 · 担当者 3 名 ·
メンテナーはふだん 3 日以内に返信
-
Improve navigation links in Core Features and Integrated Workflows対応中かも @tomi-rli が 19 日前に担当しました。 オープンHomepage
OpenEnergyPlatform/oeplatform#2746 · 担当者 1 名 ·
メンテナーはふだん 3 日以内に返信
-
Enhance the new OEP homepage対応中かも @jh-RLI が 19 日前に担当しました。 オープンHomepage
OpenEnergyPlatform/oeplatform#2745 · 担当者 2 名 ·
メンテナーはふだん 3 日以内に返信
-
Display child nodes in the OEO Viewer Graph View対応中かも @jh-RLI が 23 日前に担当しました。 オープンoeo viewer
OpenEnergyPlatform/oeplatform#2739 · 担当者 1 名 ·
メンテナーはふだん 3 日以内に返信
OpenEnergyPlatform/oeplatform の issue をすべて見る
似ている issue
-
needs-triage
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
flashinfer-ai/flashinfer#9803 ·
メンテナーはふだん 1 日以内に返信
-
bug frontend good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
oscarbol09/thesisforge#61 ·
-
api bug performance
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
oscarbol09/audiobard#159 ·
-
area:web p2 product:business triage:active type:bug
難易度 1/5 1時間未満 初心者へのやさしさ 89/100
cuadrao-ai/argus#2328 ·
メンテナーはふだん 1 日以内に返信
-
bug frontend good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
nikhilb2/simple_invoicing#907 ·