Skip to content

Return a completed result from BatchLogRecordProcessor#forceFlush after shutdown - #9083

Open
TimurRakhmatullin86 wants to merge 1 commit into
open-telemetry:mainfrom
TimurRakhmatullin86:fix/blp-force-flush-after-shutdown
Open

TimurRakhmatullin86 wants to merge 1 commit into
open-telemetry:mainfrom
TimurRakhmatullin86:fix/blp-force-flush-after-shutdown

Conversation

@TimurRakhmatullin86

Copy link
Copy Markdown
Contributor

Summary

Same hang pattern as #9082 but in BatchLogRecordProcessor. BatchLogRecordProcessor.forceFlush() invoked after shutdown() returns a CompletableResultCode that never completes:

  1. shutdown() runs: worker.shutdown() flips isShutdown and sets continueWork = false. The worker thread exits.
  2. A caller invokes processor.forceFlush() afterwards. It delegates to worker.forceFlush(), which CASes flushRequested from null and signal.offer(true).
  3. No thread is left to drain flushRequested or succeed() it. The future stays pending.
  4. Callers that block on it (join(), whenComplete(...).join(...)) wait until their own timeout.

Fix

Mirror the no-op success behavior that Worker.shutdown() already uses when called twice:

@Override
public CompletableResultCode forceFlush() {
  if (worker.isShutdown()) {
    return CompletableResultCode.ofSuccess();
  }
  return worker.forceFlush();
}

The internal Worker.forceFlush() that Worker.shutdown() itself calls stays unchanged — the shutdown routine still runs its final flush even after it sets isShutdown = true.

Test

forceFlushAfterShutdownCompletes shuts the processor down, then calls forceFlush() and verifies the returned result is already done and successful. Without the fix the result stays pending and the test blocks on the assertion.

@TimurRakhmatullin86
TimurRakhmatullin86 requested a review from a team as a code owner November 30, 2026 16:30
…er shutdown

Same hang pattern as BatchSpanProcessor: after shutdown() the worker
thread has flipped isShutdown and exited. A later call to forceFlush()
CASes a fresh flushRequested and offers the signal, but nothing is
left to drain it or call succeed() on the returned future.

Guard the public forceFlush() with the worker's isShutdown atomic so
it returns CompletableResultCode.ofSuccess() when the processor is
already shut down. The internal Worker.forceFlush() path that
shutdown() itself uses stays untouched, because shutdown() still
needs the final flush after it sets isShutdown.

Test: shutdown() first, then processor.forceFlush() returns an
already-done successful result. Without the fix the result stays
pending and the test blocks on the assertion.
@opentelemetry-pr-dashboard

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

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-11-30 17:02 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.
  • Should this be with the author? Comment /dashboard route:author to route it back.
  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Nov 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.52%. Comparing base (2aec7ba) to head (a0d0097).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9083      +/-   ##
============================================
- Coverage     90.52%   90.52%   -0.01%     
  Complexity    11243    11243              
============================================
  Files          1039     1039              
  Lines         30678    30681       +3     
  Branches       4015     4015              
============================================
+ Hits          27772    27774       +2     
  Misses         1928     1928              
- Partials        978      979       +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.

1 participant