wangdengshan created LIVY-1001: ---------------------------------- Summary: 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
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} {color:#57d9a3} _private synchronized void ref(RSCConf config) throws IOException {_{color} _{color:#57d9a3}if (refCount.get() != 0) {{color}_ _{color:#57d9a3}refCount.incrementAndGet();{color}_ _{color:#57d9a3}return;{color}_ _{color:#57d9a3}}{color}_ _{color:#57d9a3}Utils.checkState(server == null, "Server already running but ref count is 0.");{color}_ _{color:#57d9a3}if (server == null) {{color}_ _{color:#57d9a3}try {{color}_ _{color:#57d9a3}server = new RpcServer(config);{color}_ _{color:#57d9a3}} catch (InterruptedException ie) {{color}_ _{color:#57d9a3}throw Utils.propagate(ie);{color}_ _{color:#57d9a3}}{color}_ _{color:#57d9a3}}{color}_ _{color:#57d9a3}refCount.incrementAndGet();{color}_ _{color:#57d9a3}}{color}_ _{color:#57d9a3}synchronized void unref() {{color}_ _{color:#57d9a3}if (refCount.decrementAndGet() == 0) {{color}_ _{color:#57d9a3}server.close();{color}_ _{color:#57d9a3}server = null;{color}_ _{color:#57d9a3}}{color}_ _{color:#57d9a3}}{color}_ {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)