Skip to content

Conversation

@yanghua
Copy link
Contributor

@yanghua yanghua commented Dec 9, 2018

What is the purpose of the change

This pull request fixes SQL-client throws exception when paging through finished batch query

Brief change log

  • Fix SQL-client throws exception when paging through finished batch query

Verifying this change

This change added tests and can be verified as follows:

  • testRetrieveBoundedStreamQueryExecutionChangelog()
  • testRetrieveBoundedStreamQueryExecutionTable()
  • testRetrieveResultAfterBatchQueryFinished

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (yes / no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (yes / no)
  • The serializers: (yes / no / don't know)
  • The runtime per-record code paths (performance sensitive): (yes / no / don't know)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: (yes / no / don't know)
  • The S3 file system connector: (yes / no / don't know)

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

@yanghua yanghua force-pushed the FLINK-10964 branch 2 times, most recently from facbf46 to f92058a Compare December 9, 2018 13:14
Copy link
Contributor

@twalthr twalthr left a 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);
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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);
Copy link
Contributor

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.

@yanghua yanghua force-pushed the FLINK-10964 branch 2 times, most recently from 340128a to 51fa4b1 Compare January 7, 2019 12:49
@yanghua
Copy link
Contributor Author

yanghua commented Jan 8, 2019

Travis CI failed due to FLINK-11280. cc @twalthr

Copy link
Contributor

@twalthr twalthr left a 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) {
Copy link
Contributor

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 {
Copy link
Contributor

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.

@yanghua
Copy link
Contributor Author

yanghua commented Jan 15, 2019

@twalthr I have updated this PR.

@twalthr
Copy link
Contributor

twalthr commented Feb 19, 2019

Thank you @yanghua. I will take care of merging this...

twalthr pushed a commit to twalthr/flink that referenced this pull request Feb 19, 2019
@asfgit asfgit closed this in adc5eef Feb 19, 2019
asfgit pushed a commit that referenced this pull request Feb 19, 2019
asfgit pushed a commit that referenced this pull request Feb 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants