Skip to content

fix(sdk): snapshot pending exports during forceFlush - #9005

Open
nikhilred2619 wants to merge 1 commit into
open-telemetry:mainfrom
nikhilred2619:fix/8995-forceflush-race
Open

nikhilred2619 wants to merge 1 commit into
open-telemetry:mainfrom
nikhilred2619:fix/8995-forceflush-race

Conversation

@nikhilred2619

Copy link
Copy Markdown

Fixes #8995

Summary

SimpleLogRecordProcessor.forceFlush() and SimpleSpanProcessor.forceFlush() pass the live pendingExports set to CompletableResultCode.ofAll().

Because completed exports are removed concurrently, the set can change between the size calculation and iteration. This can leave the aggregated forceFlush() result incomplete even after every export has finished.

This change:

  • Takes a snapshot of pendingExports before passing it to CompletableResultCode.ofAll() in both processors.
  • Ensures the aggregate result counts and iterates over a consistent collection.
  • Preserves the existing export completion and pending-export tracking behavior.

Regression Tests

Added coverage for both log and span processors, including:

  • forceFlush() with no pending exports.
  • Failed exports and failure propagation.
  • Repeated forceFlush() calls after exports complete.
  • Exports completing concurrently with forceFlush().
  • Concurrent export completion during shutdown().

The concurrency tests exercise bounded races. They do not force the exact problematic interleaving, but verify that the aggregate result is complete once all relevant exports have completed.

Validation

Tested locally on macOS using Eclipse Temurin JDK 25.0.5.

  • ./gradlew :sdk:logs:test :sdk:trace:test — Passed
  • ./gradlew :sdk:logs:check :sdk:trace:check — Passed
  • git diff --check — Passed

All checks completed successfully.

@nikhilred2619
nikhilred2619 requested a review from a team as a code owner November 5, 2026 13:51
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-11-05 14:20 UTC

Review the latest changes.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Nov 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.37%. Comparing base (1acb73a) to head (446e874).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #9005   +/-   ##
=========================================
  Coverage     90.37%   90.37%           
- Complexity    11012    11013    +1     
=========================================
  Files          1020     1020           
  Lines         30119    30119           
  Branches       3932     3932           
=========================================
+ Hits          27219    27220    +1     
  Misses         1941     1941           
+ Partials        959      958    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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.

SimpleLogRecordProcessor/SimpleSpanProcessor.forceFlush() result never completes when an export completes while ofAll() counts the pending set

1 participant