Single-commit fast path for application tables in the system database - #156
Open
SamuelXing wants to merge 2 commits into
Open
Single-commit fast path for application tables in the system database#156SamuelXing wants to merge 2 commits into
SamuelXing wants to merge 2 commits into
Conversation
…ame guidance for the fast path
SamuelXing
force-pushed
the
feat/system-datasource
branch
from
August 7, 2026 05:11
4c1e40c to
4bc639f
Compare
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.
Closes #155, follow-up to #153.
If your app tables live in the same database as the
dbosschema, the two-commit protocol is wasted work — one commit could cover the writes and the checkpoint together. The catch: the SDK can't safely detect that a user-built datasource points at the system DB (sqlx pools have no identity comparison, and a wrong guess would break atomicity).So instead of detecting, the provider hands it out:
provider.system_datasource()builds a datasource from its own pool, so sameness is true by construction.transaction_onsees the flag and takes a single-commit fast path — body and checkpoint in one transaction, no witness table, no crash window.Why it matters: same-DB users used to choose between
ctx.transaction(one commit, but onlyParam's six types) and a manual datasource (native connection, but two commits). Now they get the native connection — jsonb, arrays, uuid, existing sqlx code — at one commit.Notes:
PgDataSource::newnever takes the fast path, even if pointed at the system DB. The flag is crate-private; only the provider can set it, so it can't be wrong.Tests: sqlite single-commit + no witness table + exactly-once replay; failure rollback and error replay; hermetic Postgres binding jsonb and bigint[] natively.