Repository navigation
fix(runtime): preserve transactions on idempotency conflicts - #52
Merged
Merged
Conversation
…pin neighbouring cells The conflict-safe idempotency claim chose its path from the raw `db.schemaDialect?.name`, while every other dialect decision in MonoSystem uses `getSchemaDialect(db).name`, which treats a driver without a declared dialect as postgres. A PostgreSQL-compatible driver that declares no dialect therefore kept the aborted-transaction defect. The claim now resolves the dialect the same way, and returns the typed rejection explicitly instead of relying on fall-through. Tests: add the no-declared-dialect driver cell (fails with the raw read), and a real-PostgreSQL SERIALIZABLE cell. The SERIALIZABLE cell behaves the same before and after the change (the winner's finish() reads the key, so PostgreSQL reports 40001 for both INSERT forms); it is registered as a pinned neighbouring cell, not as a reproduction of the defect. Registry row now names the isolation and dialect-resolution axes and drops the undefined label. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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
On PostgreSQL, when two dispatches carrying the same idempotency key arrive concurrently for the first time, the second dispatch's
_DispatchIdempotency_insert fails with a unique violation after the first one commits. A unique violation aborts the PostgreSQL transaction, andclaimDispatchIdempotencyRowthen reads the conflicting row inside that transaction, so the duplicate dispatch returned SQLSTATE25P02(current transaction is aborted) instead of the documented idempotency result (replayed, or the typedIdempotencyError).The claim now uses
INSERT ... ON CONFLICT DO NOTHING RETURNINGon PostgreSQL, PGLite and SQLite, so a conflict is not an error, the transaction stays usable, and the stored state maps to the existing typed errors through one shared helper. MySQL, which has no dispatch transactions, keeps the previous unique-error path.The defect was found by a downstream application (Mesh) while integrating its
GenerationOutcomefeature (issue #884 in that project's tracker). The application will consume the published interaqt fix instead of adding a local workaround.Scope of the defect
25P02replayed/ typedIdempotencyError40001, retried byrunWithTransactionRetryUnder SERIALIZABLE the framework's own flow already produced a retryable
40001before this change: the winner'sfinish()reads the key after inserting it and the loser read it throughload(), so PostgreSQL's serializable conflict detection reports a serialization failure for both INSERT forms. The fix therefore changes only the default isolation level. The SERIALIZABLE test is a pinned neighbouring cell, not a reproduction of the defect.Review follow-up
getSchemaDialect(db).name, like every other dialect decision inMonoSystem. A driver that declares noschemaDialectis treated as postgres; with the rawdb.schemaDialect?.nameread it silently kept the defect.Validation
MonoSystem.ts, the READ COMMITTED real-PostgreSQL race and the PGLite claim-conflict cell fail (25P02); with the fix they pass.npm run check— passed.npm run test:postgres— 11 files, 53 tests passed; includes the two-Controller race for winner commit and winner rollback, and the SERIALIZABLE cell.npm test— 236 files passed, 15 skipped; 2,804 tests passed, 71 skipped.🤖 Generated with Claude Code