honcho/src/crud
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
..
__init__.py perf: add redis caching and reduce embedding API calls (#372) 2026-02-13 00:53:46 -05:00
collection.py Refactor cache to store data rather than orm objects (#395) 2026-02-23 16:03:29 -05:00
deriver.py Modify Queue Status to only relevant tasks (#398) 2026-02-23 22:54:21 -05:00
document.py fix: Remove noisy sentry error on llm failure and upgrade deps (#396) 2026-02-23 15:53:29 -05:00
message.py perf: add redis caching and reduce embedding API calls (#372) 2026-02-13 00:53:46 -05:00
peer.py Use savepoints to prevent race condition in get_or_create chain (#399) 2026-02-23 23:28:04 -05:00
peer_card.py Use savepoints to prevent race condition in get_or_create chain (#399) 2026-02-23 23:28:04 -05:00
representation.py feat: consolidate db calls in session context (#380) 2026-02-13 11:54:41 -05:00
session.py Use savepoints to prevent race condition in get_or_create chain (#399) 2026-02-23 23:28:04 -05:00
webhook.py feat: API renaming and cleanup 2026-01-12 16:50:40 -05:00
workspace.py Use savepoints to prevent race condition in get_or_create chain (#399) 2026-02-23 23:28:04 -05:00