Repository navigation
Conversation
The deferred factory registers the process context before constructing the integration, and the delegate is swapped only after construction returns. Awaiting the registration latch could therefore wake the test thread before construction completed, failing the constructions == 1 assertion. Await whenAvailable instead, which fires after the swap, and drop the now-unused registration latch. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: cgcote <5115638+cgcote@users.noreply.github.com>
Contributor
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
This branch has not been deployed
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.
What Does This Do
Makes
DeferredProfilingContextIntegrationTest.deferredConstructionDoesNotRunOnTheCallingThread()wait until the deferred profiling integration has actually been swapped in before it asserts on the result. This is a test-only change, and all existing assertions are unchanged.Motivation
Root cause: The test waited on
FakeProcessContext.registered. InAgent.deferDdprofContextIntegration, the deferred factory callsregisterProcessContext(classLoader)first, which releases that latch, and only then constructsDatadogProfilingIntegration(Agent.java:1561-1562).DeferredProfilingContextIntegration.initialize()swaps the delegate only afterfactory.call()returns. So the test thread could wake up between registration and construction, and fail with:The test now registers
integration.whenAvailable(available::countDown)before it releases the gate, and waits on that latch. The callback is queued under the same lock as the delegate write, so it runs only after the swap. The now-unusedFakeProcessContext.registeredlatch is removed.Impact (Datadog Flaky Test Management):
datadog.trace.bootstrap.DeferredProfilingContextIntegrationTest.deferredConstructionDoesNotRunOnTheCallingThread().e8567673b55aae2b. Attempt-to-fix ID:PXS9RZ(DD_PXS9RZ).Additional Notes
Testing (run in the Bits Code session, as reported by the session):
registerProcessContextand construction (local experiment only, since reverted). With that delay, the original test failed withexpected: <1> but was: <0>at line 72. The fixed test passed with the same delay: 9 tests, 0 failures../gradlew :dd-java-agent:agent-bootstrap:test --tests 'datadog.trace.bootstrap.DeferredProfilingContextIntegrationTest' --rerun, 5 runs on unmodified production code: all passed, 9 tests and 0 failures each time../gradlew :dd-java-agent:agent-bootstrap:spotlessCheck: passed.Risks: Very low. Only the test changes, and there are no production code changes. There are no sleeps, timeout changes, relaxed assertions or quarantines.
Prepared in Bits Code session: https://app.datadoghq.com/code/6c755f89-8f5b-4850-aea7-dc3c6e85191b
This PR was opened by the dd-trace Flaky-Test ROI Recommender via Bits Code.
Contributor Checklist
type:label, acomp:label,tag: ai generatedandtag: no release notes(test-only).Jira ticket: N/A
PR by Bits - View session in Datadog
Comment @DataDog to request changes