This is an automated email from the ASF dual-hosted git repository.

pdallig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zeppelin.git


The following commit(s) were added to refs/heads/master by this push:
     new 5ae2aaebbc [ZEPPELIN-5737] try to avoid deadlock
5ae2aaebbc is described below

commit 5ae2aaebbcb4aaec617c30a3e7f128fa5f2b7906
Author: Philipp Dallig <philipp.dal...@gmail.com>
AuthorDate: Mon May 16 09:37:27 2022 +0200

    [ZEPPELIN-5737] try to avoid deadlock
    
    ### What is this PR for?
    This pull request is to prevent a deadlock which occurs in connection with 
a fast cancel in the LazyOpenInterpreter.
    
    This PR should also correct the closing of interpreters which are not 
LazyOpenInterpreter.
    
    ### What type of PR is it?
    * Bug Fix
    
    ### What is the Jira issue?
    * https://issues.apache.org/jira/browse/ZEPPELIN-5737
    
    ### How should this be tested?
    * CI
    * manual
    
    ### Questions:
    * Does the licenses files need to update? No
    * Is there breaking changes for older versions? No
    * Does this needs documentation? No
    
    Author: Philipp Dallig <philipp.dal...@gmail.com>
    
    Closes #4369 from Reamer/interpreter_deadlock and squashes the following 
commits:
    
    c7b4f2c99 [Philipp Dallig] [ZEPPELIN-5737] try to avoid deadlock
---
 .../zeppelin/interpreter/LazyOpenInterpreter.java    | 20 +++++++++-----------
 .../interpreter/remote/RemoteInterpreterServer.java  |  2 +-
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git 
a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/LazyOpenInterpreter.java
 
b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/LazyOpenInterpreter.java
index 3e1e49075f..f794a58283 100644
--- 
a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/LazyOpenInterpreter.java
+++ 
b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/LazyOpenInterpreter.java
@@ -59,13 +59,13 @@ public class LazyOpenInterpreter
   }
 
   @Override
-  public synchronized void open() throws InterpreterException {
-    if (opened == true) {
+  public void open() throws InterpreterException {
+    if (opened) {
       return;
     }
 
     synchronized (intp) {
-      if (opened == false) {
+      if (!opened) {
         try {
           intp.open();
           opened = true;
@@ -88,7 +88,7 @@ public class LazyOpenInterpreter
   @Override
   public void close() throws InterpreterException {
     synchronized (intp) {
-      if (opened == true) {
+      if (opened) {
         intp.close();
         opened = false;
       }
@@ -96,9 +96,7 @@ public class LazyOpenInterpreter
   }
 
   public boolean isOpen() {
-    synchronized (intp) {
-      return opened;
-    }
+    return opened;
   }
 
   @Override
@@ -115,8 +113,9 @@ public class LazyOpenInterpreter
 
   @Override
   public void cancel(InterpreterContext context) throws InterpreterException {
-    open();
-    intp.cancel(context);
+    if (opened) {
+      intp.cancel(context);
+    }
   }
 
   @Override
@@ -142,8 +141,7 @@ public class LazyOpenInterpreter
   public List<InterpreterCompletion> completion(String buf, int cursor,
       InterpreterContext interpreterContext) throws InterpreterException {
     open();
-    List completion = intp.completion(buf, cursor, interpreterContext);
-    return completion;
+    return intp.completion(buf, cursor, interpreterContext);
   }
 
   @Override
diff --git 
a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterServer.java
 
b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterServer.java
index 6b499fa623..1388347f57 100644
--- 
a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterServer.java
+++ 
b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterServer.java
@@ -490,7 +490,7 @@ public class RemoteInterpreterServer extends Thread
           Iterator<Interpreter> it = interpreters.iterator();
           while (it.hasNext()) {
             Interpreter inp = it.next();
-            boolean isOpen = false;
+            boolean isOpen = true;
             if (inp instanceof LazyOpenInterpreter) {
               LazyOpenInterpreter lazy = (LazyOpenInterpreter) inp;
               isOpen = lazy.isOpen();

Reply via email to