Skip to content

LinkedBlockingMultiQueue.add_sub_queue does not insert new priority groups by priority (pyamber) #6925

Closed as duplicate

Description

@aglinxinyuan

What happened?

In the Python worker's LinkedBlockingMultiQueue, add_sub_queue appends new priority groups in registration order instead of inserting them by priority, so control-priority ordering breaks whenever a data channel happens to register before a control channel.

There is already an xfail pinning this in amber/src/test/python/core/models/test_internal_queue.py:

@pytest.mark.xfail(
    reason=(
        "LinkedBlockingMultiQueue.add_sub_queue does not currently insert new "
        "priority groups ahead of lower-priority ones, so registering data before "
        "control can break control-priority ordering."
    )
)
def test_control_elements_dequeue_before_data_even_if_data_channel_registered_first(...):
    queue.put(data)  # registers the data channel first
    queue.put(dcm)   # registers the control channel later
    assert queue.get() is dcm   # FAILS today: data dequeues first

Effects:

  • Control messages (pause, EndWorker, stats queries) can queue behind data on a worker whose first-ever received element was data — delaying control responsiveness in exactly the situations control priority exists for.
  • InternalQueue.peek() (added in fix(amber): treat a queued coordinator reply as processed work in EndWorker #6916 for EndWorker diagnostics) reports the wrong head in the same situation — a cosmetic consequence, the drained/not-drained decision does not depend on it.

The fix is in add_sub_queue / the priority-group bookkeeping in amber/src/main/python/core/util/customized_queue/linked_blocking_multi_queue.py (~:415-431): insert the new priority group at its sorted position (and update the sub-queue selector's iteration state) instead of appending. Fix should flip the existing xfail to a passing test (test-first).

How to reproduce?

Run the xfail test above without the marker:

cd amber && python -m pytest "src/test/python/core/models/test_internal_queue.py::TestInternalQueue::test_control_elements_dequeue_before_data_even_if_data_channel_registered_first" --runxfail

Version/Branch

main (observed at 429be11).

Activity

  1. added theissue type on Jul 27, 2026
  2. mengw15 commented on Jul 27, 2026

    @mengw15
    Contributor

    Might be a duplicated issue
    #6905

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions