[NO ISSUE][STO] Only delete allocated components
Change-Id: I372127a0dec21148efa1a94cf6c976818963d761
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2671
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: abdullah alamoudi <bamousaa@gmail.com>
Reviewed-by: Murtadha Hubail <mhubail@apache.org>
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMHarness.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMHarness.java
index 59f48d4..644508e 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMHarness.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMHarness.java
@@ -829,19 +829,24 @@
throws HyracksDataException {
BlockingIOOperationCallbackWrapper ioCallback =
new BlockingIOOperationCallbackWrapper(lsmIndex.getIOOperationCallback());
- boolean deleteMemoryComponent;
+ boolean deleteMemoryComponent = false;
synchronized (opTracker) {
waitForFlushesAndMerges();
ensureNoFailedFlush();
- // We always start with the memory component
- ILSMMemoryComponent memComponent = lsmIndex.getCurrentMemoryComponent();
- deleteMemoryComponent = predicate.test(memComponent);
- if (deleteMemoryComponent) {
- // schedule a delete for flushed component
- ctx.reset();
- ctx.setOperation(IndexOperation.DELETE_MEMORY_COMPONENT);
- // ScheduleFlush is actually a try operation
- scheduleFlush(ctx, ioCallback);
+ if (lsmIndex.isMemoryComponentsAllocated()) {
+ // We always start with the memory component
+ ILSMMemoryComponent memComponent = lsmIndex.getCurrentMemoryComponent();
+ deleteMemoryComponent = predicate.test(memComponent);
+ if (deleteMemoryComponent) {
+ // schedule a delete for flushed component
+ ctx.reset();
+ ctx.setOperation(IndexOperation.DELETE_MEMORY_COMPONENT);
+ // ScheduleFlush is actually a try operation
+ scheduleFlush(ctx, ioCallback);
+ } else {
+ // shouldn't try to delete disk components while memory component is still there
+ return;
+ }
}
}
// Here, we are releasing the opTracker to allow other operations:
@@ -862,6 +867,9 @@
for (ILSMDiskComponent component : diskComponents) {
if (predicate.test(component)) {
ctx.getComponentsToBeMerged().add(component);
+ } else {
+ // can't delete components while newer ones are still there
+ break;
}
}
if (ctx.getComponentsToBeMerged().isEmpty()) {