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

[FLINK-33018][Tests] Fix flaky test when cancelling source #19

Merged

Conversation

RyanSkraba
Copy link

We sometimes observe the test failure described in FLINK-33018

Expected :["1", "2", "3"]
Actual   :["1", "2"]

This occurs because the thread running the source is explicitly cancelled in the finally clause. Unlike the other tests in this class, the source thread should run to completion and finish when the last message ID ("3") arrives without external intervention.

In rare cases, it was possible for the explicit cancel() to happen after the two records arrived, but before the third record causes the source to cleanly shut itself down and finish.

This is fixed by no longer waiting for any records to arrive, just letting the thread run to completion, and then testing the results.

I checked this by running this particular test as a @RepeatedTest(100_000). I have never observed the behaviour described in the issue after this change, but I've noticed that with or without the change, this test will consistently fail after the 16,248-16,250th execution, during the thread.start().

Copy link
Contributor

@MartijnVisser MartijnVisser left a comment

Choose a reason for hiding this comment

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

@RyanSkraba Thank you!

@MartijnVisser MartijnVisser merged commit f5372f2 into apache:main Sep 28, 2023
3 checks passed
@boring-cyborg
Copy link

boring-cyborg bot commented Sep 28, 2023

Awesome work, congrats on your first merged pull request!

@RyanSkraba RyanSkraba deleted the rskraba/FLINK-33018-flaky-cancel branch September 29, 2023 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants