honcho/src/routers
Vineeth Voruganti 5a42f9b3cd
Use savepoints to prevent race condition in get_or_create chain (#399)
* fix: Use savepoints to prevent race condition in get_or_create chain

Replace commit()/rollback() with begin_nested() savepoints in
get_or_create_workspace, get_or_create_peers, and get_or_create_session
so that an IntegrityError rollback in a nested call doesn't undo flushed
work from the caller. Moves transaction commit responsibility to the
outermost caller and defers cache operations to post-commit callbacks
on GetOrCreateResult.

Closes DEV-1321

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: Add missing commit and post_commit in chat endpoint

The chat() endpoint in routers/peers.py called get_or_create_peers()
but discarded the result without committing or invoking post_commit().
This meant new peers created lazily via SDK chat calls were never
persisted, and cache invalidation was skipped.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 23:28:04 -05:00
..
conclusions.py feat: API renaming and cleanup 2026-01-12 16:50:40 -05:00
keys.py feat: Add get summaries endpoints & Custom Timestamps (#185) 2025-08-12 17:19:53 -04:00
messages.py switch OTEL metrics to prometheus (#344) 2026-01-25 17:26:42 -05:00
peers.py Use savepoints to prevent race condition in get_or_create chain (#399) 2026-02-23 23:28:04 -05:00
sessions.py feat: consolidate db calls in session context (#380) 2026-02-13 11:54:41 -05:00
webhooks.py feat: API renaming and cleanup 2026-01-12 16:50:40 -05:00
workspaces.py Use savepoints to prevent race condition in get_or_create chain (#399) 2026-02-23 23:28:04 -05:00