Uploaded image for project: 'Kylin'
  1. Kylin
  2. KYLIN-2973

Potential issue of not atomically update cube instance map

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • v2.6.0
    • None
    • None

    Description

      P1

              try {
                  getStore().putResource(cube.getResourcePath(), cube, CUBE_SERIALIZER);
              } catch (IllegalStateException ise) {
                  logger.warn("Write conflict to update cube " + cube.getName() + " at try " + retry + ", will retry...");
                  if (retry >= 7) {
                      logger.error("Retried 7 times till got error, abandoning...", ise);
                      throw ise;
                  }
      
                  cube = reloadCubeLocal(cube.getName());
                  update.setCubeInstance(cube);
                  retry++;
                  cube = updateCubeWithRetry(update, retry);
              }
      

      P2

              if (toRemoveResources.size() > 0) {
                  for (String resource : toRemoveResources) {
                      try {
                          getStore().deleteResource(resource);
                      } catch (IOException ioe) {
                          logger.error("Failed to delete resource " + toRemoveResources.toString());
                      }
                  }
              }
      

      P3

              cubeMap.put(cube.getName(), cube);
      

      There's a chance like:

      1. Thread t1, goes into P2;
      2. Then Thread t2, goes into P1, P2, P3; the cube instance in the map will be updated by t2
      3. Then Thread t1 goes into P3; the cube instance in the map will be updated by t1, which is not correct

      Attachments

        Issue Links

          Activity

            People

              yaho Zhong Yanghong
              yaho Zhong Yanghong
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: