Github user zzcclp commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/2045#discussion_r173886926
  
    --- Diff: 
core/src/main/java/org/apache/carbondata/core/locks/CarbonLockUtil.java ---
    @@ -107,4 +115,37 @@ public static int getLockProperty(String property, int 
defaultValue) {
         }
       }
     
    +  /**
    +   * Currently the segment lock files are not deleted immediately when 
unlock,
    +   * so it needs to delete expired lock files before delete loads.
    +   */
    +  public static void deleteExpiredSegmentLockFiles(CarbonTable 
carbonTable) {
    +    LoadMetadataDetails[] details =
    +        
SegmentStatusManager.readLoadMetadata(carbonTable.getMetadataPath());
    +    if (details != null && details.length > 0) {
    +      AbsoluteTableIdentifier absoluteTableIdentifier = 
carbonTable.getAbsoluteTableIdentifier();
    +      long segmentLockFilesPreservTime =
    +          
CarbonProperties.getInstance().getSegmentLockFilesPreserveHours();
    +      long currTime = System.currentTimeMillis();
    +      for (LoadMetadataDetails oneRow : details) {
    +        if (oneRow.getVisibility().equalsIgnoreCase("false") ||
    +            SegmentStatus.SUCCESS == oneRow.getSegmentStatus() ||
    +            SegmentStatus.LOAD_FAILURE == oneRow.getSegmentStatus() ||
    +            SegmentStatus.LOAD_PARTIAL_SUCCESS == 
oneRow.getSegmentStatus() ||
    +            SegmentStatus.COMPACTED == oneRow.getSegmentStatus()) {
    +          String location = CarbonTablePath
    +              .getLockFilesDirPath(absoluteTableIdentifier.getTablePath()) 
+
    +              CarbonCommonConstants.FILE_SEPARATOR +
    +              CarbonTablePath.addSegmentPrefix(oneRow.getLoadName()) + 
LockUsage.LOCK;
    --- End diff --
    
    Done


---

Reply via email to