Github user manishgupta88 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1844#discussion_r164338912
--- Diff:
core/src/main/java/org/apache/carbondata/core/statusmanager/SegmentStatusManager.java
---
@@ -700,11 +708,30 @@ public static Boolean
checkIfAnyLoadInProgressForTable(CarbonTable carbonTable)
SegmentStatus segmentStatus = loaddetail.getSegmentStatus();
if (segmentStatus == SegmentStatus.INSERT_IN_PROGRESS ||
segmentStatus ==
SegmentStatus.INSERT_OVERWRITE_IN_PROGRESS) {
- loadInProgress = true;
+ loadInProgress =
+
checkIfValidLoadInProgress(carbonTable.getAbsoluteTableIdentifier(),
+ loaddetail.getLoadName());
}
}
}
return loadInProgress;
}
+ /**
+ * This method will check for valid IN_PROGRESS segments.
+ * Tries to acquire a lock on the segment and decide on the stale
segments
+ * @param absoluteTableIdentifier
+ *
+ */
+ public static Boolean checkIfValidLoadInProgress(AbsoluteTableIdentifier
absoluteTableIdentifier,
+ String loadId) {
+ ICarbonLock segmentLock =
CarbonLockFactory.getCarbonLockObj(absoluteTableIdentifier,
+ CarbonTablePath.addSegmentPrefix(loadId) + LockUsage.LOCK);
+ try {
+ return !segmentLock.lockWithRetries(1, 5);
--- End diff --
Make the retrycountinterval to 0 as if after 1st time we are not able to
acquire the lock that means it is a valid InProgress segment.
!segmentLock.lockWithRetries(1, 0)
---