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

Propagate stream cancellation causes #27266

Merged

Conversation

@jrudolph
Copy link
Member

jrudolph commented Jul 4, 2019

This PR is focussed on adding APIs and machinery to provide cancellation causes across stages and reactive streams interfaces. The new APIs are (so far) completely optional:

  • A reactive streams subscription can implement SubscriptionWithCancelException if it wants to support that feature
  • There's a new GraphStage.cancel(cause) method that can be used to provide a cause (otherwise, SubscriptionWithCancelException.NoMoreElementsNeeded is used)
  • There's a new OutHandler.onDownstreamFinished(cause) method to override if you want access to (or to propagate) the cancellation cause. If not overridden it calls the old method.
  • Similar APIs (SubSink etc.) have already also been adapted.

These changes should be completely transparent and only noticeable to those parties that implement the APIs.

It still needs to be discussed, if providing a cause should be optional or not. As a follow up we should

  • revisit all the places where our own stages implement onDownstreamFinish and make sure to use the new version and propagate causes if possible
  • change the behavior of how cancelStage will propagate to output, currently it completes neighboring outputs but it should maybe fail them by default instead.

I'll create follow up tickets to those.

Refs #23908

@akka-ci
Copy link

akka-ci commented Jul 4, 2019

Test FAILed.

Copy link
Member

helena left a comment

Looks good to me, but I am just getting back into Akka streams after a few years.

@jrudolph jrudolph force-pushed the jrudolph:jr/w/23908-streams-cancellation-exception branch from 4a3ca06 to 58951cf Jul 17, 2019
@akka-ci
Copy link

akka-ci commented Jul 17, 2019

Test FAILed.

@jrudolph jrudolph force-pushed the jrudolph:jr/w/23908-streams-cancellation-exception branch from 58951cf to 05fa234 Jul 17, 2019
@akka-ci
Copy link

akka-ci commented Jul 17, 2019

Test FAILed.

@jrudolph jrudolph force-pushed the jrudolph:jr/w/23908-streams-cancellation-exception branch from 05fa234 to 5eb51cc Jul 17, 2019
@akka-ci
Copy link

akka-ci commented Jul 17, 2019

Test FAILed.

@jrudolph jrudolph force-pushed the jrudolph:jr/w/23908-streams-cancellation-exception branch from 3125d0c to 4e2c79e Jul 23, 2019
@akka-ci akka-ci added validating and removed needs-attention labels Jul 23, 2019
@jrudolph jrudolph changed the title [WIP] Streams cancellation exception Propagate stream cancellation causes Jul 23, 2019
@jrudolph jrudolph marked this pull request as ready for review Jul 23, 2019
@akka-ci akka-ci added tested and removed validating labels Jul 23, 2019
@akka-ci
Copy link

akka-ci commented Jul 23, 2019

Test PASSed.

1 similar comment
@akka-ci
Copy link

akka-ci commented Jul 23, 2019

Test PASSed.

object SubscriptionWithCancelException {
case object NoMoreElementsNeeded extends RuntimeException with NoStackTrace
case object StageWasCompleted extends RuntimeException with NoStackTrace
}

This comment has been minimized.

@helena

helena Jul 24, 2019

Member

I wonder if SubscriptionWithCancellationException is better

This comment has been minimized.

@helena

helena Jul 24, 2019

Member

Now I see it is better in line with cancel, disregard.

This comment has been minimized.

@jrudolph

jrudolph Aug 8, 2019

Author Member

Yeah, hard to say. Maybe the default exception should have a less verbose shortcut anyway and then the name doesn't matter as much in user facing API.

jrudolph added 20 commits Jul 4, 2019
Also deprecate onDownstreamFinish() so that no one calls the wrong one
accidentally
@raboof raboof force-pushed the jrudolph:jr/w/23908-streams-cancellation-exception branch from fd0f47a to 632896f Aug 16, 2019
@akka-ci
Copy link

akka-ci commented Aug 16, 2019

Test PASSed.

@patriknw patriknw merged commit 16033ea into akka:master Aug 16, 2019
3 checks passed
3 checks passed
Jenkins PR Validation Test PASSed. 4712 tests run, 461 skipped, 0 failed.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
typesafe-cla-validator All users have signed the CLA
Details
johanandren added a commit to johanandren/akka that referenced this pull request Aug 28, 2019
* base functionality
* fix-restart-flow
* Fix subSource / subSink cancellation handling
* GraphStage-fix
* Fix ambiguity between complete and cancellation (for isAvailable / grab)
* rename lastCancellationCause
* add mima
* fix cancellation cause propagation in OutputBoundary
* Fix cancellation cause propagation in SubSink
* Add cancellation cause logging to Flow.log
* add more comments about GraphStage portState internals
* Add some assertions in onDownstreamFinish to prevent wrong usage
* Also deprecate onDownstreamFinish() so that no one calls the wrong one
accidentally
* add SubSinkInlet.cancel(cause)
* Propagate causes in two other places
* Suggest to use `cancel(in, cause)` but don't deprecate old one
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

7 participants
You can’t perform that action at this time.