-
Notifications
You must be signed in to change notification settings - Fork 2k
fix(topology): Fix for issue causing stalling on shutdown for sinks configured w/ disk buffers #24949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix(topology): Fix for issue causing stalling on shutdown for sinks configured w/ disk buffers #24949
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -148,6 +148,15 @@ impl RunningTopology { | |
| pub fn stop(self) -> impl Future<Output = ()> { | ||
| // Update the API's health endpoint to signal shutdown | ||
| self.running.store(false, Ordering::Relaxed); | ||
|
|
||
| // Signal all sinks to flush their partial batches and stop accepting | ||
| // input. Without this, sinks rely on the natural stream EOF which only | ||
| // arrives after upstream sources fully shut down, leaving sinks idle | ||
| // for up to `batch.timeout_secs` while holding a partial batch. | ||
| for (_, trigger) in self.detach_triggers { | ||
| trigger.into_inner().cancel(); | ||
|
Comment on lines
+156
to
+157
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Canceling every sink Useful? React with 👍 / 👎. |
||
| } | ||
|
|
||
| // Create handy handles collections of all tasks for the subsequent | ||
| // operations. | ||
| let mut wait_handles = Vec::new(); | ||
|
|
@@ -651,6 +660,12 @@ impl RunningTopology { | |
| // info about which sinks are having their buffers reused and treat them differently | ||
| // at other stages. | ||
| buffer_tx.insert((*key).clone(), self.inputs.get(key).unwrap().clone()); | ||
| } else if wait_for_sinks.contains(key) { | ||
| // Cancel the trigger so the old sink shuts down immediately | ||
| // instead of draining its entire buffer, which blocks the reload. | ||
| if let Some(trigger) = self.detach_triggers.remove(key) { | ||
| trigger.into_inner().cancel(); | ||
|
Comment on lines
+666
to
+667
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In Useful? React with 👍 / 👎. |
||
| } | ||
| } | ||
| self.remove_inputs(key, diff, new_config).await; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bit about "stop accepting input" makes me more than a little nervous. Could this cause problems if upstream sources send more events?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my manual testing before this change vector would stall on shutdown. With this change it takes a few seconds but I believe that is the time it takes to complete a round trip request of the payload to S3 (was a little less than 100MB).
I believe data will still be in the channel, orphaned. This data will be lost on shutdown, however this already occurs if the 60s timeout expires. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory the best option would be to stop accepting input, drain all channels, then await until disk flushes have completed, then proceed with rest of shutdown
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm considering dropping this commit as its not really related to the original reported issue anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this. We should keep this fix as short as possible.