Skip to content

LIVY-1030 cleanup of context and clients#506

Merged
lmccay merged 1 commit into
apache:masterfrom
edwardcapriolo:LIVY-1030
Jan 21, 2026
Merged

LIVY-1030 cleanup of context and clients#506
lmccay merged 1 commit into
apache:masterfrom
edwardcapriolo:LIVY-1030

Conversation

@edwardcapriolo

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

An NPE, some unused variables, and a more clear design for the client factories
https://issues.apache.org/jira/browse/LIVY-1030

How was this patch tested?

Unit tests.

Please review https://livy.incubator.apache.org/community/ before opening a pull request.

@edwardcapriolo edwardcapriolo force-pushed the LIVY-1030 branch 2 times, most recently from f361c55 to e2b933d Compare January 9, 2026 18:59

@lmccay lmccay left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tests are failing for this pull request.

@edwardcapriolo

edwardcapriolo commented Jan 16, 2026

Copy link
Copy Markdown
Contributor Author

@lmccay Hadoop 3.5.0 is now min java 17. Spark 3.4 has minimum java 17. Lets remove the java8 branch builder and move this project forward. It isn't possible to fix things into the "deep past"

@lmccay

lmccay commented Jan 16, 2026

Copy link
Copy Markdown
Contributor

@lmccay Hadoop 3.5.0 is now min java 17. Spark 3.4 has minimum java 17. Lets remove the java8 branch builder and move this project forward. It isn't possible to fix things into the "deep past"

This requires a larger discussion than here on a specific pull request. It is a discussion that would need to be had on the plans for the next release. I am supportive of it, in general, but again, it needs discussion on the dev@ list. Feel free to start the DISCUSS.

@edwardcapriolo

Copy link
Copy Markdown
Contributor Author

@lmccay Also

the errors:

at org.apache.livy.thriftserver.LivyThriftSessionManager.$anonfun$openSession$2(LivyThriftSessionManager.scala:269)
at scala.concurrent.Future$.$anonfun$apply$1(Future.scala:659)
...
Cause: java.io.IOException: RSCClient instance stopped.
at org.apache.livy.rsc.RSCClient.stop(RSCClient.java:245)
at org.apache.livy.rsc.RSCClient.connectionError(RSCClient.java:155)
at org.apache.livy.rsc.RSCClient.access$300(RSCClient.java:51)
at org.apache.livy.rsc.RSCClient$1.onFailure(RSCClient.java:95)
at org.apache.livy.rsc.Utils$2.operationComplete(Utils.java:108)
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:590)
at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:583)
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:559)
at io.netty.util.concurrent.DefaultPromise.access$200(DefaultPromise.java:35)
at io.netty.util.concurrent.DefaultPromise$1.run(DefaultPromise.java:503)

I think this entire suite is flakey, Just my opinion but they fail sometimes when i run master. They fail randomly quite often.

@lmccay

lmccay commented Jan 16, 2026

Copy link
Copy Markdown
Contributor

@lmccay Also

the errors:

at org.apache.livy.thriftserver.LivyThriftSessionManager.$anonfun$openSession$2(LivyThriftSessionManager.scala:269) at scala.concurrent.Future$.$anonfun$apply$1(Future.scala:659) ... Cause: java.io.IOException: RSCClient instance stopped. at org.apache.livy.rsc.RSCClient.stop(RSCClient.java:245) at org.apache.livy.rsc.RSCClient.connectionError(RSCClient.java:155) at org.apache.livy.rsc.RSCClient.access$300(RSCClient.java:51) at org.apache.livy.rsc.RSCClient$1.onFailure(RSCClient.java:95) at org.apache.livy.rsc.Utils$2.operationComplete(Utils.java:108) at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:590) at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:583) at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:559) at io.netty.util.concurrent.DefaultPromise.access$200(DefaultPromise.java:35) at io.netty.util.concurrent.DefaultPromise$1.run(DefaultPromise.java:503)

I think this entire suite is flakey, Just my opinion but they fail sometimes when i run master. They fail randomly quite often.

We should revisit those then. If there is no JIRA then go ahead and file one and target 0.10.0 release. NOTE: if we drop java 8 altogether at that time, it may be a 1.0.0.

There are plenty of PRs that aren't failing these, so trying a rerun should get a pass at some point.
I've rerun a couple on your PRs, not sure if it includes this one, and they were still failing.

I'm going to be out of pocket for a bit - maybe will make it back later this evening but heading out now.

@lmccay

lmccay commented Jan 16, 2026

Copy link
Copy Markdown
Contributor

Oh, this is indeed the one that I retried a couple times.

@edwardcapriolo

Copy link
Copy Markdown
Contributor Author

As it relates to Java 8. I used to be a system admin, and I am all about backwards compatibility. But for realism sake: Spark is at 3.5 (17) and 4.X. I find it really hard to believe someone would pick up livy trunk today, and say "I really want to run new shiny living on spark 2.3 and hadoop 2.4 on java 8". Likewise I cant imagine anyone using livy-0.7 on spark2 and then saying "i need this critical bug fix in trunk" I would say branch off an old one.

@lmccay

lmccay commented Jan 17, 2026

Copy link
Copy Markdown
Contributor

As it relates to Java 8. I used to be a system admin, and I am all about backwards compatibility. But for realism sake: Spark is at 3.5 (17) and 4.X. I find it really hard to believe someone would pick up livy trunk today, and say "I really want to run new shiny living on spark 2.3 and hadoop 2.4 on java 8". Likewise I cant imagine anyone using livy-0.7 on spark2 and then saying "i need this critical bug fix in trunk" I would say branch off an old one.

Again, this is a community decision and not one to make at a pull request level. Bring it to the dev@ list and drive the DISCUSS, change the PR to pass in current project state or wait for the community to bring it up.

It's not getting merged while failing test runs on currently supported Java versions and we aren't dropping support for a java version for a clean up pull request failing tests. There are aspects to consider in dropping the version of java than just dropping support that need to be discussed as well. We will need to determine the near term policy on java 17+ syntax and the effect on backports while previous lines are still technically supported and may need at least security patches. These are the sorts of things that make it a larger discussion.

@edwardcapriolo

edwardcapriolo commented Jan 17, 2026

Copy link
Copy Markdown
Contributor Author

@lmccay

It's not getting merged while failing test runs on currently supported Java versions and we aren't dropping support for a java version for a clean up pull request failing tests.

Of course, I wouldn't ask you to merge something that is breaking. Have you looked at the PR? All i did was change a method that returns a null to a method that returns Option.

Did I actually produce bad code or is this simply flaky builds?
java8 has optional support, so i don't see why it would break?

I observe these test fail on MASTER

edward@fedora:~/incubator-livy$ git log | head -10 
commit 284467b98b8f086cb3cf9a6813873141bced5dc2
Author: Edward Capriolo <edlinuxguru@gmail.com>
Date:   Fri Jan 16 10:24:14 2026 -0500

    LIVY-1029 modernize versions (#505)


[INFO] --- surefire:2.22.1:test (default-test) @ livy-rsc ---
[WARNING]  Parameter 'systemProperties' is deprecated: Use systemPropertyVariables instead.
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.apache.livy.rsc.TestJobHandle
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.082 s - in org.apache.livy.rsc.TestJobHandle
[INFO] Running org.apache.livy.rsc.TestSparkClient
[ERROR] Tests run: 19, Failures: 0, Errors: 18, Skipped: 0, Time elapsed: 28.672 s <<< FAILURE! - in org.apache.livy.rsc.TestSparkClient
[ERROR] testSyncRpc(org.apache.livy.rsc.TestSparkClient)  Time elapsed: 5.65 s  <<< ERROR!
java.util.concurrent.ExecutionException: java.io.IOException: RSCClient instance stopped.
	at org.apache.livy.rsc.TestSparkClient.runTest(TestSparkClient.java:593)
	at org.apache.livy.rsc.TestSparkClient.runTest(TestSparkClient.java:580)
	at org.apache.livy.rsc.TestSparkClient.testSyncRpc(TestSparkClient.java:202)
Caused by: java.io.IOException: RSCClient instance stopped.

It isn't a reason to block my commit because the tests don't run at all :). This is the exact reason I reached out to the incubator-ml to come on as a committer, because I think maybe no one is aware that the builds don't work, or they dont seem to care.

@lmccay

lmccay commented Jan 17, 2026

Copy link
Copy Markdown
Contributor

@lmccay

It's not getting merged while failing test runs on currently supported Java versions and we aren't dropping support for a java version for a clean up pull request failing tests.

Of course, I wouldn't ask you to merge something that is breaking. Have you looked at the PR? All i did was change a method that returns a null to a method that returns Option.

Did I actually produce bad code or is this simply flaky builds? java8 has optional support, so i don't see why it would break?

I observe these test fail on MASTER

edward@fedora:~/incubator-livy$ git log | head -10 
commit 284467b98b8f086cb3cf9a6813873141bced5dc2
Author: Edward Capriolo <edlinuxguru@gmail.com>
Date:   Fri Jan 16 10:24:14 2026 -0500

    LIVY-1029 modernize versions (#505)


[INFO] --- surefire:2.22.1:test (default-test) @ livy-rsc ---
[WARNING]  Parameter 'systemProperties' is deprecated: Use systemPropertyVariables instead.
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.apache.livy.rsc.TestJobHandle
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.082 s - in org.apache.livy.rsc.TestJobHandle
[INFO] Running org.apache.livy.rsc.TestSparkClient
[ERROR] Tests run: 19, Failures: 0, Errors: 18, Skipped: 0, Time elapsed: 28.672 s <<< FAILURE! - in org.apache.livy.rsc.TestSparkClient
[ERROR] testSyncRpc(org.apache.livy.rsc.TestSparkClient)  Time elapsed: 5.65 s  <<< ERROR!
java.util.concurrent.ExecutionException: java.io.IOException: RSCClient instance stopped.
	at org.apache.livy.rsc.TestSparkClient.runTest(TestSparkClient.java:593)
	at org.apache.livy.rsc.TestSparkClient.runTest(TestSparkClient.java:580)
	at org.apache.livy.rsc.TestSparkClient.testSyncRpc(TestSparkClient.java:202)
Caused by: java.io.IOException: RSCClient instance stopped.

It isn't a reason to block my commit because the tests don't run at all :). This is the exact reason I reached out to the incubator-ml to come on as a committer, because I think maybe no one is aware that the builds don't work, or they dont seem to care.

Well, I built master and those tests pass. I build with your patch applied and it fails. Deterministically, with the error that you show above. Built the same way with the docker build. Have you tried building master without your change? What run is the above output from?

I do see other pull requests with the builds passing.

Note that the build command that I am using is the following which is also being fixed in the docs as the proper build command [1]:

docker run --rm -it -v $(pwd):/workspace -v $HOME/.m2:/root/.m2 livy-ci mvn clean package -Pspark3 -Pscala-2.12

I am leaving your community complaints aside, as we try and work through your contirbutions for the value that they can provide.

  1. https://issues.apache.org/jira/browse/LIVY-1031

@edwardcapriolo

edwardcapriolo commented Jan 17, 2026

Copy link
Copy Markdown
Contributor Author

@lmccay

[WARNING] Parameter 'systemProperties' is deprecated: Use systemPropertyVariables instead.
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.apache.livy.rsc.TestJobHandle
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.387 s - in org.apache.livy.rsc.TestJobHandle
[INFO] Running org.apache.livy.rsc.TestSparkClient
^Cedward@fedora:~/incubator-livy$ export JAVA_HOME=/usr/lib/jvm/java-17-temurin-jdk/

Clean checkout java 17 first RSC method hands then fails. But if you say it works maybe ill try something else. Don't take it as a "complaint about the community". I am am just presenting what I observer. There are 90 pull requests here, because getting engagement is a challenge. If the project was supper healthy someone might answer back the people who send pr. I am trying to look forward. For example, this project has scalatra, which itself I think is a rather dead scala framework and its a versions maybe 5 years old, It a deep hole. You cant just upgrade anymore, the project has forked and etc etc. I do apprecate that you have run the PRs and I totally admit i could be wrong about the state of some of them, as I switch gears here and there trying to get this or that working.

@edwardcapriolo

edwardcapriolo commented Jan 17, 2026

Copy link
Copy Markdown
Contributor Author

@lmccay You are right. I found an issue I created.

    //Note. Your compiler or IDE may identify this method as unused
    //tests fail without it
    public void handle(ChannelHandlerContext ctx, RemoteDriverAddress msg) {

Note to other developers: The test Running org.apache.livy.rsc.TestSparkClient often creates a fork-bomb situation on my computer by rapidly launching multiple sparks on my system creating memory pressure. But they do run once you movedto a computer with ~16GB of ram or keep your browser closed to save RAM.

Comment thread rsc/src/main/java/org/apache/livy/rsc/ContextLauncher.java
Comment thread rsc/src/main/java/org/apache/livy/rsc/ContextLauncher.java
Comment thread rsc/src/main/java/org/apache/livy/rsc/ContextLauncher.java
Comment thread api/src/main/java/org/apache/livy/LivyClientBuilder.java
@edwardcapriolo edwardcapriolo requested a review from lmccay January 18, 2026 16:18
@edwardcapriolo

Copy link
Copy Markdown
Contributor Author

Additionally I have created https://issues.apache.org/jira/browse/LIVY-1033. I do not believe I ever had R on my system and my command line invocations never failed.

@lmccay lmccay left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@edwardcapriolo - thank you for the additional context through the code review comments. That was very helpful. I've resolved those as accepted. I did come across this one question for you though. I did approve the rerun of the tests and they passed which is great progress!

try {
task.run();
} finally {
boolean ignored = confFile.delete();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@edwardcapriolo - is this 'ignored' somehow used? Is it not scoped to this finally block only?

@edwardcapriolo edwardcapriolo Jan 20, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

My IDE will mark unused variables as yellow. You have a few options two of which:

  1. you could add a log statement
  2. you can name the variable 'ignored'

I strive to make as many files as possible "fully green". Here i took option 2. Explicitly ignored not ignored because I was unaware of a return.

Screenshot From 2026-01-20 12-36-56

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Screenshot From 2026-01-20 12-38-14

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please remove that. I spent time trying to figure out why it was necessary. We don't need your IDE to be fully green here. :)

@edwardcapriolo edwardcapriolo Jan 20, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think its good practice. Ignore return values is usually a findbugs warning. Like "mkdir() returns 1 when it fails to make the directory."
https://softdevbuilttolast.wordpress.com/2010/03/23/findbugs-help-create-robust-code-with-the-checkreturnvalue-annotation/

The yellow in my IDE is what called my attention to the initial real null pointer issue in the loop that processes the classpath

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove it or replace it with logging which will actually do something. It is not an existing practice in that file to add local vars that have no value and that may look like a bug. I can see a log message at least adding value in case it failed to delete.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. I agree that is the right coarse of action add a logging message.

@edwardcapriolo edwardcapriolo requested a review from lmccay January 20, 2026 19:24

@lmccay lmccay left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1

@edwardcapriolo

edwardcapriolo commented Jan 21, 2026

Copy link
Copy Markdown
Contributor Author

@lmccay Thank you. Since we are PR buddies may you look at this one :) #507 it should be a slam dunk. Famous last words

@lmccay lmccay left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@edwardcapriolo - did you just add the bump versions commit to this with this last iteration? Why mix them?

@edwardcapriolo

Copy link
Copy Markdown
Contributor Author

@edwardcapriolo - did you just add the bump versions commit to this with this last iteration? Why mix them?

I cleaned this up. My bad. Switching branches a often. 2x check for me.

@lmccay lmccay left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1

@lmccay lmccay merged commit 674ac00 into apache:master Jan 21, 2026
4 checks passed
@lmccay

lmccay commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

@edwardcapriolo - thanks for your contribution. This has been merged and will be included in the next release off of master!

@edwardcapriolo

Copy link
Copy Markdown
Contributor Author

@edwardcapriolo - thanks for your contribution. This has been merged and will be included in the next release off of master!

Thanks for your help as well.

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