Skip to content

fix(internal): fix race condition in PeriodicThread at exit - #19925

Draft
KowalskiThomas wants to merge 2 commits into
mainfrom
kowalski/fix-internal-fix-race-condition-in-periodicthread-exit
Draft

fix(internal): fix race condition in PeriodicThread at exit#19925
KowalskiThomas wants to merge 2 commits into
mainfrom
kowalski/fix-internal-fix-race-condition-in-periodicthread-exit

Conversation

@KowalskiThomas

Copy link
Copy Markdown
Collaborator

Description

Testing

Risks

Additional Notes

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codeowners resolved as

Resolved from the full PR diff against main using the target branch CODEOWNERS file.
CODEOWNERS team requests not listed below are not required by the current file set.

ddtrace/internal/_threads.cpp                                           @DataDog/apm-core-python
releasenotes/notes/fix-periodic-thread-shutdown-crash-9d607049f923733a.yaml  @DataDog/apm-python

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Circular import analysis

⚠️ Existing circular imports

There are 3 circular imports that already exist on the base branch and have not been changed by this PR.

ddtrace.llmobs -> ddtrace.llmobs._evaluators -> ddtrace.llmobs._evaluators.format -> ddtrace.llmobs._experiment -> ddtrace.llmobs
ddtrace.errortracking._handled_exceptions.bytecode_injector -> ddtrace.errortracking._handled_exceptions.callbacks -> ddtrace.errortracking._handled_exceptions.collector -> ddtrace.errortracking._handled_exceptions.bytecode_reporting -> ddtrace.errortracking._handled_exceptions.bytecode_injector
ddtrace.appsec._asm_request_context -> ddtrace.appsec._iast._iast_request_context_base -> ddtrace.appsec._iast._iast_env -> ddtrace.appsec._iast.reporter -> ddtrace.appsec._exploit_prevention.stack_traces -> ddtrace.appsec._asm_request_context

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 28, 2026

Copy link
Copy Markdown

Dependency direction analysis

⚠️ Existing dependency direction violations

There are 240 dependency direction violations that already exist on the base branch and have not been changed by this PR.

Show existing violations (showing 5 of 240 highest severity)
ddtrace.internal.tracemethods -×-> ddtrace.trace  (internal-core -> product:tracing, score=135)
ddtrace.appsec._listeners -×-> ddtrace.trace  (product:appsec -> product:tracing, score=133)
ddtrace.profiling.collector.stack -×-> ddtrace.trace  (product:profiling -> product:tracing, score=133)
ddtrace.llmobs._integrations.vllm -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=133)
ddtrace.internal.ci_visibility.api._base -×-> ddtrace.trace  (product:ci_visibility -> product:tracing, score=133)

To see all violations, download the layers-base.json and layers-pr.json artifacts from this CI job and run:

uv run --script scripts/import-analysis/layers.py compare layers-base.json layers-pr.json

@datadog-official

datadog-official Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Pipelines  Tests

⚠️ Warnings

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 21 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-py | build linux serverless: [arm64, cp315-cp315, v113741357-d2b8243-manylinux2014_aarch64, 1] — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-py | contrib/asgi 9/18 — 🔄 Retry may pass, looks flaky

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-py | contrib/azure_servicebus 4/4 — 🔄 Retry may pass, looks flaky

View more details · View in GitLab

View all 21 failed jobs.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 6c4973d | Docs | View more details | Give us feedback!

@pr-commenter

pr-commenter Bot commented Aug 28, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-08-28 15:41:22

Comparing candidate commit 6c4973d in PR branch kowalski/fix-internal-fix-race-condition-in-periodicthread-exit with baseline commit 5b87629 in branch main.

📊 Benchmarking dashboard

Found 0 performance improvements and 7 performance regressions! Performance is the same for 575 metrics, 10 unstable metrics, 3 known flaky benchmarks, 15 flaky benchmarks without significant changes.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

scenario:httppropagationinject-ids_only

  • 🟥 execution_time [+2.562µs; +2.702µs] or [+15.244%; +16.079%]

scenario:iastaspects-add_aspect

  • 🟥 execution_time [+8.714µs; +10.984µs] or [+8.605%; +10.846%]

scenario:iastaspects-strip_aspect

  • 🟥 execution_time [+77.620µs; +85.657µs] or [+26.451%; +29.190%]

scenario:iastaspectsospath-ospathbasename_aspect

  • 🟥 execution_time [+133.924µs; +140.071µs] or [+31.987%; +33.455%]

scenario:iastaspectssplit-rsplit_aspect

  • 🟥 execution_time [+39.510µs; +45.771µs] or [+27.376%; +31.713%]

scenario:telemetryaddmetric-1-count-metric-1-times

  • 🟥 execution_time [+588.457ns; +633.418ns] or [+21.545%; +23.191%]

scenario:tracer-small

  • 🟥 execution_time [+34.424µs; +37.367µs] or [+10.436%; +11.328%]

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:coreapiscenario-context_with_data_listeners

  • unstable execution_time [-684.071ns; +787.615ns] or [-6.262%; +7.210%]

scenario:coreapiscenario-core_dispatch_1_listener

  • unstable execution_time [-32.148ns; +34.482ns] or [-5.292%; +5.677%]

scenario:coreapiscenario-core_dispatch_50_listeners

  • unstable execution_time [-1700.460ns; +1578.017ns] or [-9.984%; +9.265%]

scenario:coreapiscenario-core_dispatch_exception_listeners

  • unstable execution_time [-1319.994ns; +1240.060ns] or [-9.958%; +9.355%]

scenario:coreapiscenario-core_dispatch_listeners

  • unstable execution_time [-339.495ns; +311.326ns] or [-9.203%; +8.440%]

scenario:coreapiscenario-core_dispatch_no_args_listeners

  • unstable execution_time [-260.405ns; +252.291ns] or [-8.862%; +8.586%]

scenario:coreapiscenario-core_dispatch_with_results_1_listener

  • unstable execution_time [-85.737ns; +67.370ns] or [-7.119%; +5.594%]

scenario:coreapiscenario-core_dispatch_with_results_50_listeners

  • unstable execution_time [-3670.949ns; +4185.392ns] or [-9.057%; +10.326%]

scenario:coreapiscenario-core_dispatch_with_results_listeners

  • unstable execution_time [-797.128ns; +759.176ns] or [-9.799%; +9.332%]

scenario:packagesupdateimporteddependencies-import_many_stdlib_cached

  • unstable execution_time [-60.333µs; +56.844µs] or [-9.692%; +9.132%]

Known flaky benchmarks

These benchmarks are marked as flaky and will not trigger a failure. Modify FLAKY_BENCHMARKS_REGEX to control which benchmarks are marked as flaky.

scenario:iastaspects-casefold_noaspect

  • 🟥 execution_time [+68.367µs; +73.200µs] or [+27.589%; +29.539%]

scenario:iastaspects-translate_aspect

  • 🟥 execution_time [+98.001µs; +103.941µs] or [+22.721%; +24.098%]

scenario:span-start

  • 🟥 execution_time [+1.152ms; +1.324ms] or [+8.086%; +9.298%]

Known flaky benchmarks without significant changes:

  • scenario:errortrackingflasksqli-baseline
  • scenario:flasksimple-iast-get
  • scenario:iastaspects-casefold_aspect
  • scenario:iastaspects-index_aspect
  • scenario:iastaspects-ljust_noaspect
  • scenario:iastaspects-lower_aspect
  • scenario:iastaspects-replace_aspect
  • scenario:iastaspects-swapcase_aspect
  • scenario:iastaspects-title_noaspect
  • scenario:iastaspects-translate_noaspect
  • scenario:iastaspects-upper_noaspect
  • scenario:packagespackageforrootmodulemapping-cache_off
  • scenario:packagespackageforrootmodulemapping-cache_on
  • scenario:sethttpmeta-all-enabled
  • scenario:telemetryaddmetric-record-100-metrics

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.

1 participant