fix(worker): hash-partition by ordering_key for multi-worker fifo#5
Merged
Conversation
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
Fix multi-worker partitioning so that messages sharing an
ordering_keyroute to a single worker. Switch fromid % total_workerstoabs(hashtext(ordering_key)) % total_workerswhen the key is set; id-based fallback preserves balance for unkeyed messages.Why
In
src/worker/batch_processor.c:460, id-based modulo spread siblings of the sameordering_keyacross worker partitions. Per-key FIFO was only enforced by aNOT EXISTSsubquery, which produced starvation and unnecessary cross-worker coordination under N>1 workers. Hash-partitioning the key restores per-key FIFO at the partition level.Validation
make installcheck-regress— 27/27 regress + 13/13 isolation (PG18, all protocols)make installcheck-tap— 3/3 (worker lifecycle intact)ordering_key_partitionpasses — withhash('partition-X') % 2 = 0, w0 locks 5 rows, w1 locks 0MakefileISOLATION listmake format/make lint/make tidy(verified by CI)Checklist
tests/isolation/specs/ordering_key_partition.spec)sql/ulak--0.0.2--0.0.3.sql— marker, no schema change)