-
Notifications
You must be signed in to change notification settings - Fork 13.8k
[FLINK-10964] SQL-client throws exception when paging through finished batch query #7265
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
Conversation
facbf46 to
f92058a
Compare
twalthr
left a comment
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.
Thank you @yanghua. I found a little bug and added some comments regarding proper test separation.
| // stop retrieval if job is done | ||
| case EOS: | ||
| stopRetrieval(); | ||
| stopRetrieval(TypedResult.ResultType.EOS); |
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.
Use a boolean flag cleanUpQuery instead.
| public volatile boolean isRunning = true; | ||
|
|
||
| //init with running status | ||
| public volatile TypedResult.ResultType jobStatus = TypedResult.ResultType.PAYLOAD; |
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.
Call this cleanUpQuery and make it a boolean.
| protected void stopRetrieval(TypedResult.ResultType jobStatus) { | ||
| // stop retrieval | ||
| refreshThread.isRunning = false; | ||
| refreshThread.jobStatus = jobStatus; |
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.
Switch these two statements because otherwise the refresh thread can already do side effects when isRunning is set to false.
|
|
||
| private static final class TestingCliResultView implements Runnable { | ||
|
|
||
| private final CliResultView resultView; |
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.
This test is meant for testing the LocalExecutor. Please don't use CLI classes here for separation of concerns. The tests should only perform calls to the executor interface.
To verify you changes feel free to create a new CliResultViewTest or something like that. The test coverage is still little for the SQL Client and needs to be improved.
| cliChangelogResultViewRunner.start(); | ||
|
|
||
| //wait enough time to trigger CliTableResultView#refresh call stopRetrieval method | ||
| Thread.sleep(5000); |
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.
Remove all hard sleeps because they make our tests slow.
340128a to
51fa4b1
Compare
|
Travis CI failed due to FLINK-11280. cc @twalthr |
twalthr
left a comment
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.
@yanghua I added another set of comments. Thanks.
| protected void stopRetrieval(boolean cleanUpQuery) { | ||
| // stop retrieval | ||
| refreshThread.isRunning = false; | ||
| if (refreshThread.isRunning) { |
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.
This change does still not fix the potential concurrency issue that I mentioned. Once isRunning is set to false the other thread might check for the cleanUpQuery value before the next line in this thread is evaluated. A proper implementation looks like:
refreshThread.cleanUpQuery = cleanUpQuery;
refreshThread.isRunning = false;
| /** | ||
| * Contains basic tests for the {@link CliResultView}. | ||
| */ | ||
| public class CliResultViewTest { |
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.
This test still uses a full integration test just to verify if a couple of calls are forwarded to the executor. Instead of setting up an entire Flink cluster for it, we should simply create a mocking executor as it is done in org.apache.flink.table.client.cli.CliClientTest and verify the calls that CliResultView performs on it.
|
@twalthr I have updated this PR. |
|
Thank you @yanghua. I will take care of merging this... |
…ough finished batch query This closes apache#7265.
…ough finished batch query This closes #7265.
…ough finished batch query This closes #7265.
What is the purpose of the change
This pull request fixes SQL-client throws exception when paging through finished batch query
Brief change log
Verifying this change
This change added tests and can be verified as follows:
Does this pull request potentially affect one of the following parts:
@Public(Evolving): (yes / no)Documentation