Repository navigation
Fix the #47 coalescing review: budgets, prefix publication, decode bound - #53
Merged
Merged
Conversation
- Each transaction costs max(1, changes) event units in peek_many and apply_many: an empty transaction still yields a receipt per binding. - apply_many publishes the longest prefix that fits one generation: it cuts to the event budget up front, then halves on a size refusal (state_limit, state_bytes_limit, invalid_generation_state) before anything commits, and acknowledges only that prefix. Freshness is carried only when the whole batch is published. - A coalesced peek decodes only commits within max_bytes of WAL past the durable offset; a transaction beyond that window is peeked alone. - apply_many refuses a batch whose first transaction is not newer than the durable offset. - The CLI admits optional max_coalesce (1 = strict per-transaction). - The phase profiler instruments peek_many/apply_many and counts published transactions; the contention evidence reports the fraction of commits a hit observed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0194kAmY4QqQGabdoB3xGFsr
dbccpage
changed the base branch from
claude/rd3-freshness-on-publish
to
main
November 11, 2026 11:08
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.
Requested by Jeremy · project thread
Follow-up to the adversarial review of #47 (already merged). Stacked on #51; only the last commit is new.
max(1, len(change))event units in bothpeek_manyandapply_many, because an empty transaction still yields anempty_transactionreceipt per binding.test_empty_transactions_count_against_the_receipt_budget: two empty txs,max_events=1,max_outputsequal to the binding count. Fails on parent (invalid_generation_state); here it publishes the admissible prefix, then the rest.apply_manypublishes the longest prefix that fits. It first cuts to the event budget, then halves onstate_limit/state_bytes_limit/invalid_generation_state, before anything commits. It acks only that prefix and carries freshness only if the whole batch went out. A single transaction that does not fit is refused as before.test_an_oversized_generation_publishes_the_largest_prefix_that_fits,test_the_group_is_held_to_max_events(now a prefix, not a refusal),test_a_single_transaction_over_max_events_is_still_refusedupto_lsn = min(frontier, durable_offset + max_bytes), so PostgreSQL decodes at most onemax_byteswindow of WAL per poll, notmax_coalesce × max_bytes. If that window holds no commit, the next transaction is peeked alone up to the frontier (the pre-#47 behavior).test_production_coalesced_peek_decodes_a_bounded_wal_window: 3000 commits,max_bytes=128 KiB,max_coalesce=1024. Every coalesced peek's upto is within the window, the window binds, oversized generations fall back to prefixes, and the oracle matches.peek_many/apply_many. Reportstransactions_published,generations_published,transactions_per_sfrom published transactions, and connections per transaction. Contention evidence addsfraction_of_commits_observed.max_coalesce(1–1024, default 64;1= strict per-transaction), passed toPostgresWorkerand printed bycheck. Documented indocs/production_profile.md.tests/test_production_cli_config.pyapply_manyrequirestransactions[0][1] > previous_offsetonce duplicates are resolved.test_a_batch_overlapping_the_durable_offset_is_refusedNot done here: the full differential suite across extremum/TopK/joins/set operations, and testing under constrained PostgreSQL memory. Both are worth a separate PR.
Local evidence (PG 16.15 + wal2json + Redis 7): the 4 new runtime tests fail on the parent branch and pass here. Production unit tests: 170 passed. Native suite: 60 passed.
blackandmypyare clean.Generated by Claude Code