Skip to content

[ZEPPELIN-2355] Livy cancel enhancements#2223

Closed
benoyantony wants to merge 4 commits intoapache:masterfrom
benoyantony:livy-cancel-enhancement
Closed

[ZEPPELIN-2355] Livy cancel enhancements#2223
benoyantony wants to merge 4 commits intoapache:masterfrom
benoyantony:livy-cancel-enhancement

Conversation

@benoyantony
Copy link

@benoyantony benoyantony commented Apr 5, 2017

What is this PR for?

The Cancel functionality for the Livy interpreter has few issues. One issue is because a variable is not published correctly. Second issue is observed when there is a delay in launching the application. Any cancel before application launch is ignored. The third issue is that Cancel is not correctly implemented for SparkSQLInterpreter.

What type of PR is it?

Bug Fix

What is the Jira issue?

https://issues.apache.org/jira/browse/ZEPPELIN-2355

How should this be tested?

The test cases are modified to test the changes.

Screenshots (if appropriate)

Questions:

  • Does the licenses files need update? No
  • Is there breaking changes for older versions? No
  • Does this needs documentation? No

@benoyantony
Copy link
Author

@zjffdu , Could you please review ?

@benoyantony benoyantony force-pushed the livy-cancel-enhancement branch from 4f1f243 to 9fc6dbf Compare April 5, 2017 04:02
@zjffdu
Copy link
Contributor

zjffdu commented Apr 5, 2017

@benoyantony Thanks for the contribution, just left some comments. And could you add test for cancellation in LivySparkSQLInterpreter

@benoyantony
Copy link
Author

@zjffdu , Will try to add the unit test for cancellation in LivySparkSQLInterpreter. Any suggestion on how to simulate a sleep in SQL ?
Also, where are the other comments ? Sorry, I am not very familiar with the github code reviews. It may be very obvious.

} else {
LOGGER.warn("cancel is not supported for this version of livy: " + livyVersion);
}
paragraphsToCancel.add(context.getParagraphId());
Copy link
Contributor

Choose a reason for hiding this comment

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

put it in if block to make the adding operation consistent with remove

Copy link
Author

Choose a reason for hiding this comment

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

Since livyVersion is available only after the session is initialized, putting it inside the if block will work based on whether livyVersion is available or not. In some cases, this , might even throw NullPointerException.

I think , it's better to simply add it and then remove it later.
If the livyVersion supports cancellation, we will cancel and remove.
If not supported, we will warn and remove.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch, we can clear paragraphsToCancel if it is not supported.

Copy link
Contributor

@zjffdu zjffdu Apr 11, 2017

Choose a reason for hiding this comment

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

Good catch, we can clear paragraphsToCancel later if it is not supported.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I will do that.

try {
LOGGER.info("Cancelling statement " + id);
cancelStatement(id);
paragraphsToCancel.remove(paragraphId);
Copy link
Contributor

Choose a reason for hiding this comment

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

It it better to put it in finally block to ensure it is removed.

Copy link
Author

Choose a reason for hiding this comment

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

I have put the removal in finally block so that paragraph is removed from the set even if cancellation is not supported in the livy version.

@zjffdu
Copy link
Contributor

zjffdu commented Apr 5, 2017

@benoyantony You can call cancel in a separate thread, the same as testSparkInterpreterRDD, let me know if you have any other questions.

@benoyantony
Copy link
Author

A testcase errored out and it seems to be unrelated.
ParagraphActionsIT.testRunOnSelectionChange

};
cancelThread.start();
boolean bCancelled = false;
for (int i=0; i <1000; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why to iterate 1000 times ?

Copy link
Author

@benoyantony benoyantony Apr 11, 2017

Choose a reason for hiding this comment

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

@zjffdu , I do not see a way to sleep inside a sql statement. So the approach was to run up to 1000 sql statements while CancelThread will call cancel on the paragraph. If the cancel works, then at least one of the statements will be cancelled and the test will be successful.

Please let me know if there is a better approach.

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, I think you don't need to run cancel in a separated thread. You can just call it as following to test. And don't use select count(1) from table_name instead, as show tables might not invoke spark jobs.

sqlInterpreter.cancel(context);
result = sqlInterpreter.interpret("select count(1) from table_name", context);

Copy link
Author

Choose a reason for hiding this comment

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

This makes sense. I have modified the test case to make above call. Still calling the cancel on a separate thread to simulate a real scenario and to make it similar to other test cases.

@benoyantony benoyantony force-pushed the livy-cancel-enhancement branch from edcbd72 to 244e6d3 Compare April 13, 2017 03:15
@zjffdu
Copy link
Contributor

zjffdu commented Apr 14, 2017

Thanks @benoyantony will merge it if no more comments.

@asfgit asfgit closed this in 861f1d8 Apr 17, 2017
@benoyantony
Copy link
Author

Thanks @zjffdu for reviewing and committing.

@benoyantony benoyantony deleted the livy-cancel-enhancement branch April 17, 2017 21:48
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.

2 participants