Skip to content

Handle pending scheduler pop failures - #492

Open
maum-meliora wants to merge 1 commit into
pion:mainfrom
maum-meliora:scheduler-pop-failures
Open

maum-meliora wants to merge 1 commit into
pion:mainfrom
maum-meliora:scheduler-pop-failures

Conversation

@maum-meliora

Copy link
Copy Markdown
Contributor

Problem

popPendingDataChunksToSend treats pendingQueue.pop as infallible,
but the pop is delegated to the stream scheduler policy and can return
an error. When it does, the chunk stays in the pending queue while the
association has already acted as if it left:

  • a DATA chunk is assigned a TSN and pushed onto the inflight queue while
    it is still in the pending queue, and its length is subtracted from
    rwnd;
  • a reset marker's stream identifier is queued for a reset that never
    had its queue entry removed;
  • the burst budget consumed for that chunk is not given back, and the
    same entry is peeked again on the next pass;
  • with nothing sent, the zero window probe branch can then pick the same
    entry.

Change

Return whether the pop succeeded and stop the pass when it fails,
before assigning TSNs, consuming rwnd, or queueing a reset. The burst
budget consumed for the failed chunk is restored, chunks moved
successfully earlier in the pass are kept, and the zero window probe is
suppressed for that pass.

The default weighted fair queueing scheduler does not fail this pop, so
this only affects associations using a custom scheduler.

Testing

  • A scheduler stub that rejects the pop covers the DATA, zero window
    probe, and reset marker paths: no TSN is assigned, no chunk is sent,
    no reset is queued, and the burst budget is restored.
  • A later-failure case: the first chunk is kept and only the failed
    chunk's budget is restored.
  • go test ./..., go test -race ./..., golangci-lint v2.10.1

A custom stream scheduler can reject a pending pop. Stop the pass
instead of assigning TSNs, consuming rwnd, or initiating resets for an
entry that was never removed, and restore the burst budget consumed for
the failed chunk while keeping chunks moved earlier in the pass.
@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.52%. Comparing base (40d10fb) to head (b51ad1e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #492      +/-   ##
==========================================
+ Coverage   85.36%   85.52%   +0.16%     
==========================================
  Files          56       56              
  Lines        5458     5484      +26     
==========================================
+ Hits         4659     4690      +31     
+ Misses        561      558       -3     
+ Partials      238      236       -2     
Flag Coverage Δ
go 85.52% <100.00%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JoTurk JoTurk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry forgot to send my pending comment

Comment thread association.go
Comment on lines +3802 to +3804
pendingQueuePopFailed = true

break

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can make writeLoop block forever. Please propagate the error.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants