Github user zzcclp commented on a diff in the pull request: https://github.com/apache/carbondata/pull/2045#discussion_r173716505 --- Diff: core/src/main/java/org/apache/carbondata/core/statusmanager/SegmentStatusManager.java --- @@ -834,6 +836,40 @@ private static void writeLoadMetadata(AbsoluteTableIdentifier identifier, } } + /** + * Currently the segment lock files are not deleted immediately when unlock, + * so it needs to delete expired lock files before delete loads. + */ + private 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 = absoluteTableIdentifier.getTablePath() + --- End diff -- Done
---