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

chore(engine): add onFailed stream processor lifecycle #4281

Merged
merged 1 commit into from
Apr 17, 2020

Conversation

deepthidevaki
Copy link
Contributor

Description

Enable stream processor lifecycle listeners to react when StreamProcessor fails.

Related issues

closes #4081

Pull Request Checklist

  • All commit messages match our commit message guidelines
  • The submitting code follows our code style
  • If submitting code, please run mvn clean install -DskipTests locally before committing

Copy link
Member

@Zelldon Zelldon left a comment

Choose a reason for hiding this comment

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

I think it is ok, not 100% what again was the problem. That the processor listeners were not able to clean up when the processor failed?

try {
asyncSnapshotDirector.closeAsync().join();
} catch (final Exception e) {
Loggers.IO_LOGGER.debug("Close snapshot director failed", e);
Copy link
Member

Choose a reason for hiding this comment

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

Why this failed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When we try to close asyncSnapshotDirector, Stream processor actor can be already closed because it has failed. AsynsSnapshotDirector tries to get the lastCommitPosition but fails because StreamProcessor is closed/failed.

Copy link
Member

Choose a reason for hiding this comment

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

this is no longer true due to removing the enforcing snapshot

assertThat(failedLatch.await(1000, TimeUnit.MILLISECONDS)).isTrue();

// then
verify(lifecycleAware, times(1)).onRecovered(any());
Copy link
Member

Choose a reason for hiding this comment

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

do we need the mock since we already have the latch with the other listener ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Found the mock useful to verify that onClose() is never called.

Copy link
Member

@Zelldon Zelldon Apr 14, 2020

Choose a reason for hiding this comment

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

Yes I saw that, but actually we should avoid to test something which should not happen, because this is often error prone and hard to test. I mean how long do you want to wait to ensure that it never happens :) It makes also hard to change things later. We should more focus on things we can verify. I really like the answer https://softwareengineering.stackexchange.com/a/345664/182290 on a related question

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Make sense. But if we don't test it, what prevents me from accidentally invoking listener:onClose() when the actor failed? Isn't part of the contract that either listener.onFailed or listener.onClose is invoked but not both?

Copy link
Member

Choose a reason for hiding this comment

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

Actually nothing. But the question is also should the test prevent you from such thing? When the end result is the same it should be fine right? No matter how many or what kind of methods are called. Is it really part of the contract ? Does it need to be? What values gives us this. As I said we should try to avoid these kind of couplings, since it makes harder to add new features.

I know I also did this sometimes, since sometimes we have the feeling that we have to make sure such thing doesn't happen. But it makes things often more complicate then it needs to be. We should try to focus on things we can guarantee and verify without using mocks. Like I put a into a function and get b, but I don't care how it is calculated. On these listeners tests it is a bit harder I know.

But what we can do is just test things which should happen. Like if something fails it should call onFailure. When I close it, it should call onClose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok 👍

Copy link
Member

@Zelldon Zelldon left a comment

Choose a reason for hiding this comment

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

👍

@deepthidevaki
Copy link
Contributor Author

bors r+

@zeebe-bors
Copy link
Contributor

zeebe-bors bot commented Apr 17, 2020

Build succeeded

@zeebe-bors zeebe-bors bot merged commit e8f532e into develop Apr 17, 2020
@zeebe-bors zeebe-bors bot deleted the 4081-onfail-listener branch April 17, 2020 14:15
github-merge-queue bot pushed a commit that referenced this pull request Apr 16, 2024
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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.

Add onFail to StreamProcessor lifecycle listener
3 participants