test(internal): add lifecycle stress / fuzzing harness for PeriodicThread#18183
Draft
r1viollet wants to merge 1 commit into
Draft
test(internal): add lifecycle stress / fuzzing harness for PeriodicThread#18183r1viollet wants to merge 1 commit into
r1viollet wants to merge 1 commit into
Conversation
…read Adds tests/internal/test_periodic_stress.py — a randomized lifecycle fuzzer that interleaves create / start / stop / join / awake / drop-last-ref / fork / gc / thread-churn across a pool of PeriodicThread and PeriodicService objects. The assertion surface is "no crash": any child killed by a signal or unexpected exception escaping the public API fails the test. Two focused regression harnesses are bundled in the same file: - test_periodic_thread_concurrent_dealloc_race (regresses PR 17485) - test_periodic_thread_stop_without_join_then_fork_repeat (PR 16955) Default budget (DD_STRESS_ITERS=200, ~4 forks) is short enough for CI (~10s). The module docstring documents how to run a longer soak when modifying ddtrace/internal/_threads.cpp or the periodic lifecycle, along with DD_STRESS_SEED for reproducing a failing run. This is the harness that surfaced PRs 17707 and 18040 (PeriodicThread.awake() blocking forever after stop()). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
tests/internal/test_periodic_stress.py— a randomized lifecyclefuzzer for
PeriodicThreadthat interleavescreate / start / stop / join / awake / drop-last-ref / fork / gc /
thread-churn across a pool of
PeriodicThreadandPeriodicServiceobjects.
This is the harness that surfaced #17707 and #18040
(
PeriodicThread.awake()blocking forever afterstop()).What's in the file
test_periodic_thread_lifecycle_stress— the randomized fuzzer.Default budget kept short for CI (
DD_STRESS_ITERS=200, ~10s).Documented env vars for soaks (
DD_STRESS_ITERS,DD_STRESS_SECONDS,DD_STRESS_SEED,DD_STRESS_POOL,DD_STRESS_FORK_EVERY,DD_STRESS_TRACE_FILE). Seed is printed on every run so a failingrandom seed can be pinned with
DD_STRESS_SEED=N.test_periodic_thread_concurrent_dealloc_race— focused regressionfor fix: periodic thread start race #17485 (refcount TOCTOU between
std::threadcreation and thelambda acquiring the GIL).
test_periodic_thread_stop_without_join_then_fork_repeat— focusedregression for fix: periodic thread after fork cleanup #16955 (
pthread_trecycling after stop-without-jointhen fork).
How to run it when modifying the periodic thread framework
The module docstring documents the exact commands. tl;dr:
Testing
All three tests pass locally on Python 3.13 in the testrunner image:
Risks
None — test-only addition. Existing test discovery and CI suites are
unchanged.
changelog/no-changelog— test-only.🤖 Generated with Claude Code