Skip to content

fix(pyamber): keep multi-queue priority groups sorted - #9586

Open
Ma77Ball wants to merge 1 commit into
apache:mainfrom
Ma77Ball:fix/pyamber-priority-queue-order
Open

Ma77Ball wants to merge 1 commit into
apache:mainfrom
Ma77Ball:fix/pyamber-priority-queue-order

Conversation

@Ma77Ball

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

  • LinkedBlockingMultiQueue.add_sub_queue inserts a new priority group at the computed index i instead of appending it, so priority_groups stays sorted and get_next/peek serve higher-priority sub-queues first regardless of registration order.

Any related issues, documentation, discussions?

Closes: #9583

How was this PR tested?

  • Run cd amber && PYTHONPATH=src/main/python python -m pytest src/test/python/core/util/customized_queue/test_linked_blocking_multi_queue.py; expect all passing, including a new case that registers the lower-priority queue first and asserts the groups are ordered by priority and the higher-priority item is served first.

Was this PR authored or co-authored using generative AI tooling?

Co-authored with Claude Opus 4.8 in compliance with ASF

LinkedBlockingMultiQueue.add_sub_queue walked priority_groups to find the slot i where a new group belongs, then appended the group to the end instead of inserting it at i, so the list stayed sorted only when sub-queues were registered in increasing-priority order. get_next and peek iterate priority_groups in list order, so a data channel (priority 1) registered before a control channel (priority 0) was served before control. The new group is now inserted at i, keeping the list sorted regardless of registration order.

test_linked_blocking_multi_queue adds a case that registers the lower-priority queue first and asserts the groups are ordered by priority and that the higher-priority item is served first.
@Yicong-Huang Yicong-Huang added release/v1.3 back porting to release/v1.3 release/v1.2 back porting to release/v1.2 labels Nov 20, 2026
@github-actions
github-actions Bot requested review from mengw15 and xuang7 November 20, 2026 23:14
@github-actions

Copy link
Copy Markdown
Contributor

Backport auto-label report

This fix: PR was checked against each actively-supported release branch. A release/* label nominates a backport target; the branch's release manager approving this PR is what sends the fix there. The required Backport Approvals check stays red until every label below is approved, so each manager either approves or removes their own label — which is why the labels left on a merged PR are exactly the branches it reached.

Release branch Analysis
✅ release/v1.3 Change detected on this branch — label added; this fix is queued to backport here. @mengw15 decides: approving sends the fix here, removing this label declines it. The merge waits on one or the other. Review requested.
✅ release/v1.2 Change detected on this branch — label added; this fix is queued to backport here. @xuang7 decides: approving sends the fix here, removing this label declines it. The merge waits on one or the other. Review requested.

Auto-label run.

@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @carloea2
    You can notify them by mentioning @carloea2 in a comment.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix pyamber release/v1.2 back porting to release/v1.2 release/v1.3 back porting to release/v1.3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Engine queue ignores channel priority when sub-queues register out of order

2 participants