[ https://issues.apache.org/jira/browse/LIVY-1001?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
wangdengshan updated LIVY-1001: ------------------------------- Description: Below is the exception stack I printed out {color:#ff8b00}2024-05-30 03:39:12 [ERROR] [LivyServer2-Background-Create-Session-Pool: Thread-139976] org.apache.livy.thriftserver.LivyThriftSessionManager:error:58 - Create session failed!{color} {color:#ff8b00}java.lang.NullPointerException{color} {color:#ff8b00} at org.apache.livy.rsc.ContextLauncher.<init>(ContextLauncher.java:86){color} {color:#ff8b00} at org.apache.livy.rsc.ContextLauncher.create(ContextLauncher.java:73){color} {color:#ff8b00} at org.apache.livy.rsc.RSCClientFactory.createClient(RSCClientFactory.java:72){color} {color:#ff8b00} at org.apache.livy.LivyClientBuilder.build(LivyClientBuilder.java:174){color} {color:#ff8b00} at org.apache.livy.server.interactive.InteractiveSession$.$anonfun$create$1(InteractiveSession.scala:195){color} {color:#ff8b00} at scala.Option.orElse(Option.scala:447){color} {color:#ff8b00} at org.apache.livy.server.interactive.InteractiveSession$.create(InteractiveSession.scala:99){color} {color:#ff8b00} at org.apache.livy.thriftserver.LivyThriftSessionManager.$anonfun$openSession$3(LivyThriftSessionManager.scala:437){color} {color:#ff8b00} at org.apache.livy.thriftserver.LivyThriftSessionManager.org$apache$livy$thriftserver$LivyThriftSessionManager$$getOrCreateLivySession(LivyThriftSessionManager.scala:340){color} {color:#ff8b00} at org.apache.livy.thriftserver.LivyThriftSessionManager$$anon$1.run(LivyThriftSessionManager.scala:454){color} {color:#ff8b00} at org.apache.livy.thriftserver.LivyThriftSessionManager$$anon$1.run(LivyThriftSessionManager.scala:450){color} {color:#ff8b00} at java.security.AccessController.doPrivileged(Native Method){color} {color:#ff8b00} at javax.security.auth.Subject.doAs(Subject.java:422){color} {color:#ff8b00} at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:2248){color} {color:#ff8b00} at org.apache.livy.thriftserver.LivyThriftSessionManager.$anonfun$openSession$4(LivyThriftSessionManager.scala:450){color} {color:#ff8b00} at scala.concurrent.Future$.$anonfun$apply$1(Future.scala:659){color} {color:#ff8b00} at scala.util.Success.$anonfun$map$1(Try.scala:255){color} {color:#ff8b00} at scala.util.Success.map(Try.scala:213){color} {color:#ff8b00} at scala.concurrent.Future.$anonfun$map$1(Future.scala:292){color} {color:#ff8b00} at scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:33){color} {color:#ff8b00} at scala.concurrent.impl.Promise.$anonfun$transform$1(Promise.scala:33){color} {color:#ff8b00} at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64){color} {color:#ff8b00} at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149){color} {color:#ff8b00} at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624){color} {color:#ff8b00} at java.lang.Thread.run(Thread.java:748){color} {color:#172b4d}By troubleshooting the code, we found that the problem may occur in the creation of RpcServer and the processing of refCount reference logic.{color} {code:java} private synchronized void ref(RSCConf config) throws IOException { if (refCount.get() != 0) { refCount.incrementAndGet(); return; } Utils.checkState(server == null, "Server already running but ref count is 0."); if (server == null) { try { server = new RpcServer(config); } catch (InterruptedException ie) { throw Utils.propagate(ie); } } refCount.incrementAndGet(); } synchronized void unref() { if (refCount.decrementAndGet() == 0) { server.close(); server = null; } } {code} {color:#172b4d}This problem will occur if an exception is thrown during the new RpcServer process{color} was: Below is the exception stack I printed out {color:#ff8b00}2024-05-30 03:39:12 [ERROR] [LivyServer2-Background-Create-Session-Pool: Thread-139976] org.apache.livy.thriftserver.LivyThriftSessionManager:error:58 - Create session failed!{color} {color:#ff8b00}java.lang.NullPointerException{color} {color:#ff8b00} at org.apache.livy.rsc.ContextLauncher.<init>(ContextLauncher.java:86){color} {color:#ff8b00} at org.apache.livy.rsc.ContextLauncher.create(ContextLauncher.java:73){color} {color:#ff8b00} at org.apache.livy.rsc.RSCClientFactory.createClient(RSCClientFactory.java:72){color} {color:#ff8b00} at org.apache.livy.LivyClientBuilder.build(LivyClientBuilder.java:174){color} {color:#ff8b00} at org.apache.livy.server.interactive.InteractiveSession$.$anonfun$create$1(InteractiveSession.scala:195){color} {color:#ff8b00} at scala.Option.orElse(Option.scala:447){color} {color:#ff8b00} at org.apache.livy.server.interactive.InteractiveSession$.create(InteractiveSession.scala:99){color} {color:#ff8b00} at org.apache.livy.thriftserver.LivyThriftSessionManager.$anonfun$openSession$3(LivyThriftSessionManager.scala:437){color} {color:#ff8b00} at org.apache.livy.thriftserver.LivyThriftSessionManager.org$apache$livy$thriftserver$LivyThriftSessionManager$$getOrCreateLivySession(LivyThriftSessionManager.scala:340){color} {color:#ff8b00} at org.apache.livy.thriftserver.LivyThriftSessionManager$$anon$1.run(LivyThriftSessionManager.scala:454){color} {color:#ff8b00} at org.apache.livy.thriftserver.LivyThriftSessionManager$$anon$1.run(LivyThriftSessionManager.scala:450){color} {color:#ff8b00} at java.security.AccessController.doPrivileged(Native Method){color} {color:#ff8b00} at javax.security.auth.Subject.doAs(Subject.java:422){color} {color:#ff8b00} at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:2248){color} {color:#ff8b00} at org.apache.livy.thriftserver.LivyThriftSessionManager.$anonfun$openSession$4(LivyThriftSessionManager.scala:450){color} {color:#ff8b00} at scala.concurrent.Future$.$anonfun$apply$1(Future.scala:659){color} {color:#ff8b00} at scala.util.Success.$anonfun$map$1(Try.scala:255){color} {color:#ff8b00} at scala.util.Success.map(Try.scala:213){color} {color:#ff8b00} at scala.concurrent.Future.$anonfun$map$1(Future.scala:292){color} {color:#ff8b00} at scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:33){color} {color:#ff8b00} at scala.concurrent.impl.Promise.$anonfun$transform$1(Promise.scala:33){color} {color:#ff8b00} at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64){color} {color:#ff8b00} at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149){color} {color:#ff8b00} at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624){color} {color:#ff8b00} at java.lang.Thread.run(Thread.java:748){color} {color:#172b4d}By troubleshooting the code, we found that the problem may occur in the creation of RpcServer and the processing of refCount reference logic.{color} {code:java} private synchronized void ref(RSCConf config) throws IOException { if (refCount.get() != 0) { refCount.incrementAndGet(); return; } Utils.checkState(server == null, "Server already running but ref count is 0."); if (server == null) { try { server = new RpcServer(config); } catch (InterruptedException ie) { throw Utils.propagate(ie); } } refCount.incrementAndGet(); } synchronized void unref() { if (refCount.decrementAndGet() == 0) { server.close(); server = null; } } {code} {color:#172b4d}This problem will occur if an exception is thrown during the new RpcServer process{color} > ContextLauncher has a potential NullPointerException exception during the > livy session creating process. > -------------------------------------------------------------------------------------------------------- > > Key: LIVY-1001 > URL: https://issues.apache.org/jira/browse/LIVY-1001 > Project: Livy > Issue Type: Bug > Components: RSC > Affects Versions: 0.8.0 > Reporter: wangdengshan > Priority: Major > Labels: patch > Original Estimate: 96h > Remaining Estimate: 96h > > Below is the exception stack I printed out > {color:#ff8b00}2024-05-30 03:39:12 [ERROR] > [LivyServer2-Background-Create-Session-Pool: Thread-139976] > org.apache.livy.thriftserver.LivyThriftSessionManager:error:58 - Create > session failed!{color} > {color:#ff8b00}java.lang.NullPointerException{color} > {color:#ff8b00} at > org.apache.livy.rsc.ContextLauncher.<init>(ContextLauncher.java:86){color} > {color:#ff8b00} at > org.apache.livy.rsc.ContextLauncher.create(ContextLauncher.java:73){color} > {color:#ff8b00} at > org.apache.livy.rsc.RSCClientFactory.createClient(RSCClientFactory.java:72){color} > {color:#ff8b00} at > org.apache.livy.LivyClientBuilder.build(LivyClientBuilder.java:174){color} > {color:#ff8b00} at > org.apache.livy.server.interactive.InteractiveSession$.$anonfun$create$1(InteractiveSession.scala:195){color} > {color:#ff8b00} at scala.Option.orElse(Option.scala:447){color} > {color:#ff8b00} at > org.apache.livy.server.interactive.InteractiveSession$.create(InteractiveSession.scala:99){color} > {color:#ff8b00} at > org.apache.livy.thriftserver.LivyThriftSessionManager.$anonfun$openSession$3(LivyThriftSessionManager.scala:437){color} > {color:#ff8b00} at > org.apache.livy.thriftserver.LivyThriftSessionManager.org$apache$livy$thriftserver$LivyThriftSessionManager$$getOrCreateLivySession(LivyThriftSessionManager.scala:340){color} > {color:#ff8b00} at > org.apache.livy.thriftserver.LivyThriftSessionManager$$anon$1.run(LivyThriftSessionManager.scala:454){color} > {color:#ff8b00} at > org.apache.livy.thriftserver.LivyThriftSessionManager$$anon$1.run(LivyThriftSessionManager.scala:450){color} > {color:#ff8b00} at java.security.AccessController.doPrivileged(Native > Method){color} > {color:#ff8b00} at > javax.security.auth.Subject.doAs(Subject.java:422){color} > {color:#ff8b00} at > org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:2248){color} > {color:#ff8b00} at > org.apache.livy.thriftserver.LivyThriftSessionManager.$anonfun$openSession$4(LivyThriftSessionManager.scala:450){color} > {color:#ff8b00} at > scala.concurrent.Future$.$anonfun$apply$1(Future.scala:659){color} > {color:#ff8b00} at > scala.util.Success.$anonfun$map$1(Try.scala:255){color} > {color:#ff8b00} at scala.util.Success.map(Try.scala:213){color} > {color:#ff8b00} at > scala.concurrent.Future.$anonfun$map$1(Future.scala:292){color} > {color:#ff8b00} at > scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:33){color} > {color:#ff8b00} at > scala.concurrent.impl.Promise.$anonfun$transform$1(Promise.scala:33){color} > {color:#ff8b00} at > scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64){color} > {color:#ff8b00} at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149){color} > {color:#ff8b00} at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624){color} > {color:#ff8b00} at java.lang.Thread.run(Thread.java:748){color} > > {color:#172b4d}By troubleshooting the code, we found that the problem may > occur in the creation of RpcServer and the processing of refCount reference > logic.{color} > {code:java} > private synchronized void ref(RSCConf config) throws IOException { > if (refCount.get() != 0) { > refCount.incrementAndGet(); > return; > } > Utils.checkState(server == null, "Server already running but ref count is > 0."); > if (server == null) { > try { > server = new RpcServer(config); > } catch (InterruptedException ie) { > throw Utils.propagate(ie); > } > } > refCount.incrementAndGet(); > } > synchronized void unref() { > if (refCount.decrementAndGet() == 0) { > server.close(); > server = null; > } > } {code} > {color:#172b4d}This problem will occur if an exception is thrown during the > new RpcServer process{color} -- This message was sent by Atlassian Jira (v8.20.10#820010)