[ 
https://issues.apache.org/jira/browse/KYLIN-2849?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16265957#comment-16265957
 ] 

liyang commented on KYLIN-2849:
-------------------------------

Looked code, the normal path is segment is deleted when an error job is 
discarded. So here we are talking about error scenario, that something went 
wrong and the orphan segment is left behind after job is discarded.

How about adding a 'force' parameter on the delete segment API to bypass the 
check? Also the API could accept UUID in addition to segment name to identify 
an error segment precisely.

> duplicate segment,cannot be deleted and data cannot be refreshed and merged
> ---------------------------------------------------------------------------
>
>                 Key: KYLIN-2849
>                 URL: https://issues.apache.org/jira/browse/KYLIN-2849
>             Project: Kylin
>          Issue Type: Bug
>          Components: Job Engine, Metadata, REST Service
>    Affects Versions: v2.0.0
>         Environment: hadoop:hadoop-2.6.0-cdh5.8.2
> hive :2.1.0
> hbase:0.98
>            Reporter: 翟玉勇
>            Assignee: Dong Li
>              Labels: scope
>         Attachments: kylin-1.png, kylin-2.png
>
>
> cube duplicate segments。
> cannot be deleted and data cannot be refreshed and merged
> {code}
> try
> curl -X DELETE 
> "http://127.0.0.1:7070/kylin/api/cubes/Remain_Cube_2/segs/20170822000000_20170823000000";
>   -H "Authorization: Basic QURNSU46S1lMSU4=" -H "Content-Type: 
> application/json;charset=UTF-8"
> Cannot delete segment '20170822000000_20170823000000' as it is neither the 
> first nor the last 
> segment.","stacktrace":"org.apache.kylin.rest.exception.InternalErrorException:
>  Cannot delete segment '20170822000000_20170823000000' as it is neither the 
> first nor the last segment
> {code}
> 暂时解决办法:
> {code}
> public CubeInstance deleteSegment(CubeInstance cube, String segmentName) 
> throws IOException {
>         if (!segmentName.equals(cube.getSegments().get(0).getName()) && 
> !segmentName.equals(cube.getSegments().get(cube.getSegments().size() - 
> 1).getName())) {
>             //throw new IllegalArgumentException("Cannot delete segment '" + 
> segmentName + "' as it is neither the first nor the last segment.");
>         }
>         CubeSegment toDelete = null;
>         for (CubeSegment seg : cube.getSegments()) {
>             if (seg.getName().equals(segmentName)) {
>                 toDelete = seg;
>             }
>         }
>         if (toDelete == null) {
>             throw new IllegalArgumentException("Cannot find segment '" + 
> segmentName + "'");
>         }
>         if (toDelete.getStatus() != SegmentStatusEnum.READY) {
>             //throw new IllegalArgumentException("Cannot delete segment '" + 
> segmentName + "' as its status is not READY. Discard the on-going job for 
> it.");
>         }
>         CubeUpdate update = new CubeUpdate(cube);
>         update.setToRemoveSegs(new CubeSegment[] { toDelete });
>         return CubeManager.getInstance(getConfig()).updateCube(update);
>     }
> {code}



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

Reply via email to