Skip to content
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

[Prism] Drain behavior #30250

Open
damondouglas opened this issue Feb 7, 2024 · 2 comments
Open

[Prism] Drain behavior #30250

damondouglas opened this issue Feb 7, 2024 · 2 comments
Assignees

Comments

@damondouglas
Copy link
Contributor

damondouglas commented Feb 7, 2024

What needs to happen?

Under #29669

The following uses an example driven approach via gherkin syntax to describe drain behavior.

Scenario: pipeline reads from Pub/Sub

Given pipeline reads from Pub/Sub subscription
  And more messages remain in the subscription
 When I trigger a drain
 Then no more mesages are read from the Pub/Sub subscription
  And the pipeline processes remaining messages read before the drain was triggered

Scenario: pipeline reads from file system

Given pipeline reads from a filesystem
  And more files are yet to be read by the pipeline
 When I trigger a drain
 Then the remaining files are read by the pipeline

Scenario: pipeline reads from Pub/Sub and reads from file system into a side input

Given pipeline reads from Pub/Sub subscription
  And more messages remain in the subscription
 When I trigger a drain
 Then no more mesages are read from the Pub/Sub subscription
  And the remaining files are read by the pipeline into the side input
  And the pipeline processes remaining messages read before the drain was triggered

Scenario: pipeline writes to Pub/Sub topic

Given pipeline writes to Pub/Sub topic
 When I trigger a drain
 Then the pipeline continues writing to the topic until it proceses all remaining in-flight elements in the pipeline
@damondouglas
Copy link
Contributor Author

@lostluck FYI

@lostluck
Copy link
Contributor

lostluck commented Feb 12, 2024

Thanks for your patience. This is all largely correct.

Drain semantics are tricky since they only apply to unbounded pipelines, since the data there is most at risk of loss when a pipeline is terminated.

Eg. The scenario for Filesystems would only apply if the reads were triggered by a batch FileIO transform. Logically a runner is not aware of how differrent elements go together in bundles, so it's not possible to stop reading new files, if the runner has elements representing them still in flight. The transform isn't aware that it can drain (outside of unbounded restriction truncation, a transform isn't drain aware).

Conversely, if the file system reader were a Watch transform, then that's semantically an unbounded transform, and all already observed files would complete processing, but no new arrivals should occur, because a Watch Transform's restriction when truncated, should prevent that, and cause the transform to Stop.

The pipeline writes to Pub/Sub topic scenario is incorrect however. A sink/writer transform doesn't do anything in particular for a drain. It will continue to write all in flight elements destined for it, and not suddenly stop. It will only stop once there are no further inbound elements, because to do otherwise is to lose data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants