o-shevchenko commented on a change in pull request #230: [WIP][LIVY-664][Server] Spark application still running when Livy session creating was rejected URL: https://github.com/apache/incubator-livy/pull/230#discussion_r323732774
########## File path: server/src/main/scala/org/apache/livy/server/SessionServlet.scala ########## @@ -131,6 +131,11 @@ abstract class SessionServlet[S <: Session, R <: RecoveryMetadata]( if (tooManySessions) { BadRequest(ResponseMessage("Rejected, too many sessions are being created!")) } else { + // LIVY-664: Check if name is duplicated before create a session + val newSessionName = sessionName(request) + if (newSessionName.isDefined && sessionManager.get(newSessionName.get).isDefined) { + BadRequest(ResponseMessage(s"Duplicate session name: ${newSessionName.get}")) + } val session = sessionManager.register(createSession(request)) Review comment: I see, `createSession(request)` function has side effect. This function builds RSC Client which starts the driver process (https://github.com/o-shevchenko/incubator-livy/blob/ef5dccbb0d15797a4bc009b78c88e3b40ff79b7d/rsc/src/main/java/org/apache/livy/rsc/RSCClientFactory.java#L72). ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services