Github user doanduyhai commented on the issue:

    https://github.com/apache/zeppelin/pull/1369
  
    @astroshim @AhyoungRyu it tooks me hours but I have found the root cause of 
the issue and it's pretty ugly. Ready to hear ?
    
    1) First issue is we **do not** set the InterpreterSetting `status` and 
`errorReason` together. For example here: 
https://github.com/apache/zeppelin/blob/master/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java#L398
    
    ```java
        ...
        setting.setStatus(InterpreterSetting.Status.DOWNLOADING_DEPENDENCIES);
        interpreterSettings.put(setting.getId(), setting);
        ...
    ``` 
    
     So here we set the status to `DOWNLOADING_DEPENDENCIES` but the 
`errorReason` stills contains the previous value, possible something like 
"Cannot download dependency x.y.z ....". That explains why we see 
    
    ```
    ...
        "status":"DOWNLOADING_DEPENDENCIES",
        "errorReason":"Could not find artifact one:two:jar:1.1.1 in central 
(http://repo1.maven.org/maven2/)",
    ...
    ```
    
    2) Second issue is more serious, it is concurrency issue. We set the status 
of the dependency download in a separate thread: 
https://github.com/apache/zeppelin/blob/master/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java#L400-L433
    
    ```java
    ...
    catch (Exception e) {
                logger.error(String.format("Error while downloading repos for 
interpreter group : %s," +
                        " go to interpreter setting page click on edit and save 
it again to make " +
                        "this interpreter work properly.",
                    setting.getGroup()), e);
                setting.setErrorReason(e.getLocalizedMessage());
                setting.setStatus(InterpreterSetting.Status.ERROR);
    ...
    ```
    
    The problem is that the initial status is set to `DOWNLOADING_DEPENDENCIES` 
and then the interpreter status is returned by the caller class to the client:  
https://github.com/apache/zeppelin/blob/master/zeppelin-server/src/main/java/org/apache/zeppelin/rest/InterpreterRestApi.java#L113-L135
    
    I added extra log message to debug:
    
    ```
                ...
                logger.info("************** DEBUG_ZEPPELIN setting status 
ERROR");
                setting.setStatus(InterpreterSetting.Status.ERROR);
                setting.setErrorReason(e.getLocalizedMessage());
                ...
    
        ...
        logger.info("************** DEBUG_ZEPPELIN setting debug " + 
setting.toDebugString());
        return new JsonResponse<>(Status.OK, "", setting).build();
        ...
    ```
    
     And below is what is displayed in the logs:
    
    ```
    INFO [2016-09-07 12:35:26,151] ({qtp240166646-20} 
InterpreterRestApi.java[updateSetting]:132) - ************** DEBUG_ZEPPELIN 
setting debug DOWNLOADING_DEPENDENCIES :
    ERROR [2016-09-07 12:35:26,539] ({Thread-25} 
InterpreterFactory.java[run]:433) - Error while downloading repos for 
interpreter group : angular, go to interpreter setting page click on edit and 
save it again to make this interpreter work properly. : Could not find artifact 
one:two:jar:1.1.25 in central (http://repo1.maven.org/maven2/)
    org.sonatype.aether.resolution.DependencyResolutionException: Could not 
find artifact one:two:jar:1.1.25 in central (http://repo1.maven.org/maven2/)
            at 
org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:375)
            at 
org.apache.zeppelin.dep.DependencyResolver.getArtifactsWithDep(DependencyResolver.java:164)
            at 
org.apache.zeppelin.dep.DependencyResolver.loadFromMvn(DependencyResolver.java:116)
            at 
org.apache.zeppelin.dep.DependencyResolver.load(DependencyResolver.java:79)
            at 
org.apache.zeppelin.dep.DependencyResolver.load(DependencyResolver.java:96)
            at 
org.apache.zeppelin.dep.DependencyResolver.load(DependencyResolver.java:88)
            at 
org.apache.zeppelin.interpreter.InterpreterFactory$3.run(InterpreterFactory.java:425)
    Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: 
Could not find artifact one:two:jar:1.1.25 in central 
(http://repo1.maven.org/maven2/)
            at 
org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:537)
            at 
org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:216)
            at 
org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:358)
            ... 6 more
    Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Could 
not find artifact one:two:jar:1.1.25 in central (http://repo1.maven.org/maven2/)
            at 
org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:971)
            at 
org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:966)
            at 
org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.flush(WagonRepositoryConnector.java:707)
            at 
org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.flush(WagonRepositoryConnector.java:701)
            at 
org.sonatype.aether.connector.wagon.WagonRepositoryConnector.get(WagonRepositoryConnector.java:452)
            at 
org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:456)
            ... 8 more
     INFO [2016-09-07 12:35:26,541] ({Thread-25} 
InterpreterFactory.java[run]:437) - ************** DEBUG_ZEPPELIN setting 
status ERROR
    ```
    
    So the `DOWNLOADING_DEPENDENCIES` status is returned to the client 
**before** the download error status is set in a **separate** thread.
    
    This issue is indeed already there in the master and it **not** related to 
this pull request


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to