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
@@ -442,10 +442,30 @@ async def _create_thread_direct(request: Request, *, metadata: dict[str, Any] |
|
||||
"parents": {},
|
||||
"created_at": now,
|
||||
}
|
||||
|
||||
async def _cleanup_partial_thread() -> None:
|
||||
delete_checkpoint = getattr(checkpointer, "adelete_thread", None)
|
||||
if callable(delete_checkpoint):
|
||||
try:
|
||||
await delete_checkpoint(thread_id)
|
||||
except Exception:
|
||||
logger.exception("[init-direct] partial checkpoint cleanup failed for %s", thread_id)
|
||||
try:
|
||||
await thread_store.delete(thread_id)
|
||||
except Exception:
|
||||
logger.exception("[init-direct] partial thread_meta cleanup failed for %s", thread_id)
|
||||
|
||||
try:
|
||||
await checkpointer.aput(config, empty_checkpoint(), ckpt_metadata, {})
|
||||
except asyncio.CancelledError:
|
||||
# A sibling seat may fail while this task is between metadata commit and
|
||||
# checkpoint creation. Compensate before propagating cancellation, under
|
||||
# shield so a second cancellation cannot abort the cleanup half-way.
|
||||
await asyncio.shield(_cleanup_partial_thread())
|
||||
raise
|
||||
except Exception:
|
||||
logger.exception("[init-direct] checkpoint create failed for %s", thread_id)
|
||||
await _cleanup_partial_thread()
|
||||
raise HTTPException(status_code=500, detail="Failed to create thread")
|
||||
return thread_id
|
||||
|
||||
|
||||
Reference in new issue
Block a user