Skip to content

fix: index concurrent first chat saves atomically - #176

Open
rudycelekli wants to merge 1 commit into
Merit-Systems:mainfrom
rudycelekli:fix/index-concurrent-chat-saves
Open

rudycelekli wants to merge 1 commit into
Merit-Systems:mainfrom
rudycelekli:fix/index-concurrent-chat-saves

Conversation

@rudycelekli

Copy link
Copy Markdown

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.

Signed-off-by: Rudy Celekli <rudy@gradiahq.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant