fix: avoid MySQL thread_meta refresh races and harden roundtable bootstrap
Skip post-commit ORM refresh on threads_meta creates so concurrent MySQL read/write-split deployments no longer fail with Could not refresh instance; clean up partial roundtable threads on checkpoint failure, and ship related position-roundtable/frontend build fixes. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
e52261fc3d
commit
a9d66536c3
12 files changed
+503
-127
No files matched your search
@@ -127,7 +127,25 @@ Clients may retry the compatibility route only for a framework/proxy-level
|
||||
`multi_agent._create_thread_direct`, exactly like multi-agent initialization;
|
||||
do not restore the old HTTP loopback to `/api/threads`, because deployed
|
||||
Gateway ports/proxies may make the automatic page initialization fail while
|
||||
later manual turns still work. Streaming stays on the existing loopback path.
|
||||
later manual turns still work. If checkpoint creation fails or the parallel seat
|
||||
task is cancelled, the helper compensates by deleting any partial checkpoint and
|
||||
metadata row (the cancellation branch runs under `asyncio.shield` so a second
|
||||
cancellation cannot abort it half-way). Streaming stays on the existing loopback
|
||||
path.
|
||||
|
||||
`ThreadMetaStore.create` never issues a post-commit `session.refresh()`. Every
|
||||
`ThreadMetaRow` column is assigned before commit and the session factory uses
|
||||
`expire_on_commit=False`, so the returned dict is built from the in-memory row.
|
||||
The removed read-back ran on a *different* pooled connection than the INSERT,
|
||||
which a MySQL read/write-splitting endpoint can route to a lagging replica — the
|
||||
row comes back empty and SQLAlchemy raises `Could not refresh instance`, surfacing
|
||||
as `500 "Failed to create thread"`. Concurrency makes that far more likely, so a
|
||||
single-user deployment never sees it. No caller uses the return value, and all
|
||||
seven call sites (`multi_agent._create_thread_direct`, `services.start_run`,
|
||||
`routers/threads.create_thread`, `roundtable_inprocess_gateway`,
|
||||
`scheduler/service`, `thread_shares`, `authz`) benefit. Keep new `create`
|
||||
implementations read-back-free; `tests/test_position_roundtable_sessions.py::
|
||||
test_thread_meta_create_never_reads_back_after_commit` guards this.
|
||||
|
||||
### Harness / App Split
|
||||
|
||||
|
||||
Reference in new issue
Block a user