[ 
https://issues.apache.org/jira/browse/STORM-3624?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ethan Li updated STORM-3624:
----------------------------
    Description: 
https://github.com/apache/storm/blob/master/storm-server/src/main/java/org/apache/storm/scheduler/resource/ResourceAwareScheduler.java#L100-L102

config() is called in multiple threads. But ArtifactoryConfigLoader.load is not 
thread-safe. For example, 
https://github.com/apache/storm/blob/master/storm-server/src/main/java/org/apache/storm/scheduler/utils/ArtifactoryConfigLoader.java#L181-L187
{code:java}
JSONObject returnValue;
        try {
            returnValue = (JSONObject) jsonParser.parse(metadataStr);
        } catch (ParseException e) {
            LOG.error("Could not parse JSON string {}", metadataStr, e);
            return null;
        }
{code}

Multiple threads use the same jsonParser and since JsonParser is not 
thread-safe, the return value will be corrupted. 


I propose to create a separate thread to load scheduler configs periodically. 
This also makes the config loading logic cleaner.

  was:
https://github.com/apache/storm/blob/master/storm-server/src/main/java/org/apache/storm/scheduler/resource/ResourceAwareScheduler.java#L100-L102

config() is called in multiple threads. But ArtifactoryConfigLoader.load is not 
thread-safe. For example, 
https://github.com/apache/storm/blob/master/storm-server/src/main/java/org/apache/storm/scheduler/utils/ArtifactoryConfigLoader.java#L181-L187
{code:java}
JSONObject returnValue;
        try {
            returnValue = (JSONObject) jsonParser.parse(metadataStr);
        } catch (ParseException e) {
            LOG.error("Could not parse JSON string {}", metadataStr, e);
            return null;
        }
{code}

Multiple threads use the same jsonParser and since JsonParser is not 
thread-safe, the return value will be corrupted. 



> Race condition on ArtifactoryConfigLoader.load
> ----------------------------------------------
>
>                 Key: STORM-3624
>                 URL: https://issues.apache.org/jira/browse/STORM-3624
>             Project: Apache Storm
>          Issue Type: Bug
>            Reporter: Ethan Li
>            Priority: Major
>
> https://github.com/apache/storm/blob/master/storm-server/src/main/java/org/apache/storm/scheduler/resource/ResourceAwareScheduler.java#L100-L102
> config() is called in multiple threads. But ArtifactoryConfigLoader.load is 
> not thread-safe. For example, 
> https://github.com/apache/storm/blob/master/storm-server/src/main/java/org/apache/storm/scheduler/utils/ArtifactoryConfigLoader.java#L181-L187
> {code:java}
> JSONObject returnValue;
>         try {
>             returnValue = (JSONObject) jsonParser.parse(metadataStr);
>         } catch (ParseException e) {
>             LOG.error("Could not parse JSON string {}", metadataStr, e);
>             return null;
>         }
> {code}
> Multiple threads use the same jsonParser and since JsonParser is not 
> thread-safe, the return value will be corrupted. 
> I propose to create a separate thread to load scheduler configs periodically. 
> This also makes the config loading logic cleaner.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to