Repository navigation
fix: index concurrent first chat saves atomically - #176
Open
rudycelekli wants to merge 1 commit into
Open
rudycelekli wants to merge 1 commit into
rudycelekli wants to merge 1 commit into
Conversation
Signed-off-by: Rudy Celekli <rudy@gradiahq.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Preserve concurrent first chat saves instead of raising a chats_pkey violation. Separate UI title and usage saves can both find an empty index, then attempt the same insert. Use one atomic upsert, updating only explicitly supplied fields and retaining the workspace guard.
Reproduction and verification
The regression exercises the actual tRPC chats.save mutation with committed migrations and real PGlite/Drizzle. Only the database driver boundary changes; SQL results and write ordering are not mocked. Concurrent first title/usage saves fail with PostgreSQL error 23505 before the fix. The sequential sparse-save and foreign-workspace control passes. Both new cases pass after the fix; focused existing router/database controls also pass (five tests across three files).
Required local pnpm check passed all six tasks (96 files / 878 tests), and pnpm build passed with owned public placeholders. Existing physical dependencies from the identical lockfile were handed off reversibly and restored; no installation, package-manager guard override, dependency or workflow change was made.
The unchanged declared Checks workflow passed on exact signed head fcf5dd5: frozen installation, full pnpm check, and complete pnpm test:runtime (two mock-model scenarios / 13 gates, including cleanup). The merge checkout tree matches the source head. Local Docker cleanup is blocked on this machine; that local runtime command is not counted as passed.
No live model, deployed PostgreSQL, production authentication or HTTP request validation claim. The native regression tests the supported tRPC/service caller with owned scope fixtures.
Scope and overlap
One chat indexing cause, with no schema, auth, model or UI changes. PR #169 focuses channel delivery/history projection and leaves this database service unchanged. Merged #123 retained the old lookup/insert sequence. Neither addresses the reproduced first-save collision.
AI assistance was used for investigation, implementation, tests and review under the submitting account. Signed DCO commit included.