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

Zhong Yanghong updated KYLIN-2973:
----------------------------------
    Description: 
P1
{code}
        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);
        }
{code}
P2
{code}
        if (toRemoveResources.size() > 0) {
            for (String resource : toRemoveResources) {
                try {
                    getStore().deleteResource(resource);
                } catch (IOException ioe) {
                    logger.error("Failed to delete resource " + 
toRemoveResources.toString());
                }
            }
        }
{code}
P3
{code}
        cubeMap.put(cube.getName(), cube);
{code}

There's a chance like:
# Thread t1, goes into P2;
# Then Thread t2, goes into P1, P2, P3; the cube instance in the map will be 
updated by t2
# Then Thread t1 goes into P3; the cube instance in the map will be updated by 
t1, which is not correct

> Potential issue of not atomically update cube instance map
> ----------------------------------------------------------
>
>                 Key: KYLIN-2973
>                 URL: https://issues.apache.org/jira/browse/KYLIN-2973
>             Project: Kylin
>          Issue Type: Bug
>            Reporter: Zhong Yanghong
>
> P1
> {code}
>         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);
>         }
> {code}
> P2
> {code}
>         if (toRemoveResources.size() > 0) {
>             for (String resource : toRemoveResources) {
>                 try {
>                     getStore().deleteResource(resource);
>                 } catch (IOException ioe) {
>                     logger.error("Failed to delete resource " + 
> toRemoveResources.toString());
>                 }
>             }
>         }
> {code}
> P3
> {code}
>         cubeMap.put(cube.getName(), cube);
> {code}
> There's a chance like:
> # Thread t1, goes into P2;
> # Then Thread t2, goes into P1, P2, P3; the cube instance in the map will be 
> updated by t2
> # Then Thread t1 goes into P3; the cube instance in the map will be updated 
> by t1, which is not correct



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to