Uploaded image for project: 'Apache Storm'
  1. Apache Storm
  2. STORM-3624

Race condition on ArtifactoryConfigLoader.load

    XMLWordPrintableJSON

Details

    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

      JSONObject returnValue;
              try {
                  returnValue = (JSONObject) jsonParser.parse(metadataStr);
              } catch (ParseException e) {
                  LOG.error("Could not parse JSON string {}", metadataStr, e);
                  return null;
              }
      

      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.

      Attachments

        Issue Links

          Activity

            People

              ethanli Ethan Li
              ethanli Ethan Li
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 2h
                  2h