Skip to content

Wait for the paused relay consumer and tighten the test's failure paths - #1829

Merged
tleonhardt merged 5 commits into
mainfrom
fix/relay-consumer-read
Nov 18, 2026
Merged

tleonhardt merged 5 commits into
mainfrom
fix/relay-consumer-read

Conversation

@tleonhardt

@tleonhardt tleonhardt commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

The paused relay test could fail on ppc64le when the child exited and returned the terminal before the consumer finished its first read. Steve Traylen’s fix gives the consumer up to five seconds to reach first_read before the test goes on to check the final output order.

This branch includes Steve’s original commit from #1826 and the payload calculation from #1825. The slack stays fixed at 16,384 bytes. Review discussion and reproduction results.

Follow-up changes

Two later commits came out of code review of the test. They change only tests/test_utils.py.

  • The consumer sets a paused event once it has read its first page, and the test waits on that event instead of polling the byte count. The consumer’s reads stop at that page until it is resumed, so the rest of the output is still in the relay when cmd2 writes after it. A timeout now fails with a message that says so. Before, it looked like the byte-count mismatch of the original race.
  • Cleanup sets lent as well as resume. A test that failed before the first lend used to leave the consumer in lent.wait(10) while cleanup joined it for the same 10 seconds. Each such failure took 10 seconds, and a join that lost the race closed the read descriptor under a live thread.
  • The consumer’s first read loop stops on end of file. End of file arrives only once cleanup closes the writer, so this stops the consumer spinning on empty reads after a failure.

Verification

Of the original fix:

With the follow-up commits:

  • On macOS arm64, both relay test cases passed in each of 5 consecutive runs.
  • A temporary copy of the test whose child exits with status 3 before writing failed in 0.02 seconds per case, on the return-code assertion. Without the lent change it took 10 seconds per case.
  • The full suite passed with 3,080 tests and 3 skips. make check and make docs-test also passed.
  • The follow-up commits have not been run on ppc64le, and no run exercised the new timeout message.

traylenator and others added 2 commits November 17, 2026 20:18
On ppc64le,
test_pipeline_writer_relay_lends_only_while_a_producer_waits[True]
failed with:

    AssertionError: assert 1114112 == 1163264

The child's last write unblocks once the relay has forwarded about
capacity + 65536 bytes, 1114112 with 64 KiB pages. The consumer may
still need more forwarded to reach first_read, and the test asserted
as soon as the lend was returned, without waiting for it.

Wait up to 5 seconds for the consumer to reach first_read. Its reads
are capped there, so the equality check still holds.
@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.75%. Comparing base (1e8abbb) to head (028faa2).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1829   +/-   ##
=======================================
  Coverage   99.75%   99.75%           
=======================================
  Files          23       23           
  Lines        6665     6665           
=======================================
  Hits         6649     6649           
  Misses         16       16           
Flag Coverage Δ
unittests 99.75% <ø> (ø)

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.

The consumer now sets an event once it has read its first page, and the
test waits on that instead of polling the byte count. A timeout fails
with a message that says so, where it used to look like the byte-count
mismatch of the original race.

The consumer's first read loop also stops on end of file, so a relay
that closes the pipe early fails the test instead of spinning.
Cleanup set resume but not lent, so a test that failed before the first
lend left the consumer in lent.wait(10) while cleanup joined it for the
same 10 seconds. Each such failure took 10 seconds, and a join that
lost the race closed the read descriptor under a live thread. Set lent
in cleanup as well.

Correct the comment on the consumer's end-of-file check, and the reason
the previous commit gave for it. The writer keeps its own write end of
the pipe, so the relay cannot close it early. End of file arrives only
once cleanup closes the writer, and the check stops the consumer
spinning on empty reads after that.
@tleonhardt tleonhardt changed the title Wait for the paused relay consumer before checking its read Wait for the paused relay consumer and tighten the test's failure paths Nov 18, 2026
A timeout on either of the consumer's waits let a slow run read ahead: past
its first page before cmd2's write, or before any lend. The test could then
pass without exercising what it is for. Its cleanup releases both waits, so
neither needs a timeout to end.
@tleonhardt
tleonhardt merged commit 56a9e56 into main Nov 18, 2026
31 checks passed
@tleonhardt
tleonhardt deleted the fix/relay-consumer-read branch November 18, 2026 00:36
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