Skip to content

[Dataflow Streaming] Fix global data stream updates in FanOutStreamingEngineWorkerHarness - #41549

Open
arunpandianp wants to merge 5 commits into
apache:masterfrom
arunpandianp:cl1023190052_fanout_worker_harness
Open

arunpandianp wants to merge 5 commits into
apache:masterfrom
arunpandianp:cl1023190052_fanout_worker_harness

Conversation

@arunpandianp

Copy link
Copy Markdown
Contributor

Fix global data stream updates, shared channel eviction, and shutdown in FanOutStreamingEngineWorkerHarness

  • Compute active direct addresses across both work and global data endpoints in closeStreamsNotIn() and only evict channels from ChannelCachingStubFactory after closing streams when no remaining endpoint references them.
  • Use createDirectGetDataStream(WindmillConnection.from(...)) for global data streams so they re-fetch stubs on reconnect/rotation (e.g. after ChannelCache refreshes), and check endpoint equality per tag key before reusing or closing global data streams.
  • Guard shutdown(), consumeWorkerMetadata(), and consumeWindmillWorkerEndpoints() with isShutdown under metadataLock to make shutdown idempotent and ignore post-shutdown metadata callbacks, and mark executor threads as daemon threads.

…viction, and shutdown in FanOutStreamingEngineWorkerHarness

- Compute active direct addresses across both work and global data endpoints
  in closeStreamsNotIn() and only evict channels from ChannelCachingStubFactory
  after closing streams when no remaining endpoint references them.
- Use createDirectGetDataStream(WindmillConnection.from(...)) for global data
  streams so they re-fetch stubs on reconnect/rotation (e.g. after ChannelCache
  refreshes), and check endpoint equality per tag key before reusing or closing
  global data streams.
- Guard shutdown(), consumeWorkerMetadata(), and consumeWindmillWorkerEndpoints()
  with isShutdown under metadataLock to make shutdown idempotent and ignore
  post-shutdown metadata callbacks, and mark executor threads as daemon threads.
@arunpandianp

Copy link
Copy Markdown
Contributor Author

R: @scwhittle @parveensania

@github-actions github-actions Bot added runners dataflow size/m M: 50-249 lines changed labels Nov 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

@codecov

codecov Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.55172% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.93%. Comparing base (f3763f8) to head (cd92baf).
⚠️ Report is 76 commits behind head on master.

Files with missing lines Patch % Lines
...ng/harness/FanOutStreamingEngineWorkerHarness.java 96.55% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #41549      +/-   ##
============================================
+ Coverage     58.88%   58.93%   +0.05%     
- Complexity     2334     2399      +65     
============================================
  Files          1136     1137       +1     
  Lines        171035   171231     +196     
  Branches       1552     1601      +49     
============================================
+ Hits         100711   100914     +203     
+ Misses        67767    67744      -23     
- Partials       2557     2573      +16     
Flag Coverage Δ
java 76.78% <96.55%> (+0.28%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- Simplify FanOutStreamingEngineWorkerHarness.closeStreamsNotIn by
  tracking candidate channel evictions in a HashSet and launching async
  closes directly instead of collecting intermediate Pair lists and
  concatenating streams, with step-by-step comments explaining stream
  closure vs. address eviction ordering.
- Pass previousBackends.windmillStreams() explicitly to
  createAndStartNewStreams for consistency with closeStreamsNotIn and
  createNewGlobalDataStreams.
- Strengthen FanOutStreamingEngineWorkerHarnessLifecycleTest to assert
  displaced work stream shutdown, add coverage for multiple work
  endpoints sharing an address with different worker tokens, and verify
  channel eviction runs only after all displaced streams finish closing.
workerMetadataConsumer.shutdownNow();
// Close all the streams blocking until this completes to not leak resources.
closeStreamsNotIn(WindmillEndpoints.none()).join();
closeStreamsNotIn(backends.get(), WindmillEndpoints.none()).join();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before we do this, should we make sure the metadataconsumer is completed so that no more backends are added? the consumer checks shutdown but then releases metadatalock so it seems racy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consumeWindmillWorkerEndpoints is also synchronizes on this and checks the isShutDown flag. So there should not be new backends set after shutdown.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah I didn't see that synchronization on this. I do wonder if we should reduce the scope of that synchronized block though to not include waiting on streams. Seems maybe unnecessary give we have the serial handling of metadata and atomic backends already.

…reams

- In FanOutStreamingEngineWorkerHarness.consumeWindmillWorkerEndpoints,
  create and install the new work and global data streams and distribute
  budget before calling closeStreamsNotIn(...).join(), removing the
  intermediate backends.set(...) and avoiding stalling replacement work
  streams behind old stream teardown.
- Add a clarifying comment in shutdown() noting mutual exclusion with
  consumeWindmillWorkerEndpoints() via synchronized(this).
- Add testWorkEndpointUpdatePublishesNewBackendsBeforeClosingDisplacedStreams
  to verify work backends and budget distribution precede displaced
  stream shutdown.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dataflow runners size/m M: 50-249 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants