Repository navigation
Conversation
Port the adapter to Storage.commit(batches, receive, context). A group of batches goes to a new commit_batches function in one round trip: it locks the session row and checks the owner once, then runs commit_batch per batch in a subtransaction, so a refusal by one of the adapter's checks keeps the batches before it and ends the call with the refusal, while any other error rolls the call back and rejects it. A batch with a document.copy starts a new call once the batches before it are durable, since the copy's source is read while preparing; every other group is one round trip. Schema version 3 also admits the sleeping task status added in 1.4.0. A round-trip test pins one query for a group of plain batches and three for a group whose last batch copies a document the earlier ones wrote.
…rite one statement per table
rgarcia
changed the base branch from
hypeship/durable-postgres-storage
to
main
November 3, 2026 15:11
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
Rebases the Postgres storage adapter onto upstream
main(which now carries pi-durable's group commit,e5c6182) and ports it to the batchedStorage.commit(batches, receive, context)contract.commit_batchesplpgsql function locks the session row and checks the owner once, then runs the existingcommit_batchper batch inside a subtransaction. A refusal by one of the adapter's checks (SQLSTATEDU003toDU009) keeps the batches before it and returns the refusal; any other error, ownership included, raises and rolls the call back.document.copystarts a new call once the batches before it are durable, because the copy's source is materialized while preparing. Everything else is one call.sleeping, added upstream in 1.4.0.kernel/pimainwas fast-forwarded to upstreammain(50af8c1); the base branchhypeship/durable-postgres-storagestarts there.Tests
PI_DURABLE_POSTGRES_URL=... vitest --run test/postgres-storage.test.ts: 72 tests pass against Postgres 17, including upstream's new conformance cases (prefix kept before a refusal, a malformed later batch, a batched copy against the earlier batches' state, receipts before resolution) on both the plain and the reopen-per-commit storages, plus a new round-trip test: one query for three plain batches, three for a group whose last batch copies a document the first two wrote.Root
tsc --noEmitand biome are clean.