mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3614] [Other] Test: NoLeakedSampler loses a still-ending sampler between its two name counts (flaky 1 != 2) #4713
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4713
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/3614
Author: @victorgabr
Created: 10/21/2026
Status: 🔄 Open
Base:
main← Head:fix/leaked-sampler-baseline📝 Commits (1)
270c208[Other] Test: NoLeakedSampler counted thread names before and after, but a sampler of a server a previous test closed keeps ending for up to a second, and losing that straggler between the two counts hid the one this server started (flaky 1 != 2, CI run 39625083194 among 929); count the new thread by identity instead and check it ends📊 Changes
1 file changed (+10 additions, -4 deletions)
View changed files
📝
serve/test_responses.py(+10 -4)📄 Description
Problem and result
serve/test_responses.pyNoLeakedSampler.test_server_close_ends_the_samplerfails at random - once in 929 tests on CI (run 39625083194, step "Run full server suite without terminal packages") and about once in four plainpython -m unittest serve.test_responsesruns on Linux, alwaysAssertionError: 1 != 2. After this change the module passes 8/8 on this machine.Cause
The test counts threads named
*(_loop)before and afterserve()and expectsbefore + 1. The name is not set on purpose: Python 3.10+ names an unnamedThreadafter its target, and the telemetry sampler (serve/telemetry.py:584,target=self._loop) shows up asThread-N (_loop).Telemetry.close()only sets_stop; the thread sits in_stop.wait(1.0)and ends up to a second after the close. A server closed by a test shortly before can still leave such a straggler:beforecounts it, it exits between the two counts, and the one thread this server started is hidden -1 != 2. The name-total check cannot tell the two threads apart.Approach
The test's own question - "one server, one sampler, and it ends with the server" - is answered by identity, not totals: record the set of sampler thread ids before, take the difference after
serve()(a straggler leaving in between cannot affect the difference), and wait for that thread to end. Product behavior is unchanged: noclose()or join changes, no sleeps added to the suite.Validation
Passed (Linux, Python 3.10.9):
AssertionError: 1 != 2locally (1 failure in 4 module runs).python -m unittest serve.test_responsesOK, plus one more on the rebased branch.Failed: none.
Not run: Windows and the 929-test suite locally (needs the engine build); the CI run will cover it.
Limits
The underlying one-second exit latency of the sampler is kept - it is the sample cadence, not a bug; only the test's counting is fixed.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.