[NO ISSUE][STO] Eliminate S Lock for Disk Components
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
- Eliminate S lock for tuples returned from disk components, since LSM
disk components only contain committed data and S lock is not needed to
prevent from reading uncommitted data.
Change-Id: Id6ec999b131cd6609d588966d7ae7788f429ab9d
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2637
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: abdullah alamoudi <bamousaa@gmail.com>
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeRangeSearchCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeRangeSearchCursor.java
index 81f4a83..fb0b9ac0 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeRangeSearchCursor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeRangeSearchCursor.java
@@ -106,8 +106,8 @@
if (!outputPriorityQueue.isEmpty()) {
PriorityQueueElement queueHead = outputPriorityQueue.peek();
if (canCallProceed) {
- resultOfSearchCallbackProceed = searchCallback.proceed(queueHead.getTuple());
if (includeMutableComponent) {
+ resultOfSearchCallbackProceed = searchCallback.proceed(queueHead.getTuple());
if (!resultOfSearchCallbackProceed) {
// In case proceed() fails and there is an in-memory component,
// we can't simply use this element since there might be a change.
@@ -150,6 +150,10 @@
includeMutableComponent = false;
}
}
+ } else {
+ // only perform locking for tuples from memory components.
+ // all tuples from disk components have already been committed, and we're safe to proceed
+ resultOfSearchCallbackProceed = true;
}
}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndexSearchCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndexSearchCursor.java
index 4d444b9..d39c601 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndexSearchCursor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndexSearchCursor.java
@@ -59,6 +59,7 @@
private List<IIndexAccessor> deletedKeysBTreeAccessors;
private RangePredicate keySearchPred;
private ILSMIndexOperationContext opCtx;
+ private boolean includeMemoryComponents;
private List<ILSMComponent> operationalComponents;
private ITupleReference currentTuple = null;
@@ -76,7 +77,7 @@
accessorIndex = 0;
this.searchPred = searchPred;
this.searchCallback = lsmInitState.getSearchOperationCallback();
-
+ includeMemoryComponents = false;
// For searching the deleted-keys BTrees.
deletedKeysBTreeAccessors = lsmInitState.getDeletedKeysBTreeAccessors();
deletedKeysBTreeCursors = new IIndexCursor[deletedKeysBTreeAccessors.size()];
@@ -87,6 +88,7 @@
if (component.getType() == LSMComponentType.MEMORY) {
// No need for a bloom filter for the in-memory BTree.
deletedKeysBTreeBloomFilters[i] = null;
+ includeMemoryComponents = true;
} else {
deletedKeysBTreeBloomFilters[i] = ((LSMInvertedIndexDiskComponent) component).getBloomFilter();
}
@@ -121,7 +123,8 @@
while (currentCursor.hasNext()) {
currentCursor.next();
currentTuple = currentCursor.getTuple();
- resultOfSearchCallBackProceed = searchCallback.proceed(currentTuple);
+ resultOfSearchCallBackProceed =
+ includeMemoryComponents && accessorIndex == 0 ? searchCallback.proceed(currentTuple) : true;
if (!resultOfSearchCallBackProceed) {
// We assume that the underlying cursors materialize their results such that
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/LSMRTreeSearchCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/LSMRTreeSearchCursor.java
index c79735f..b9e174f 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/LSMRTreeSearchCursor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/LSMRTreeSearchCursor.java
@@ -98,7 +98,8 @@
rtreeCursors[currentCursor].next();
ITupleReference currentTuple = rtreeCursors[currentCursor].getTuple();
// Call proceed() to do necessary operations before returning this tuple.
- resultOfsearchCallbackProceed = searchCallback.proceed(currentTuple);
+ resultOfsearchCallbackProceed =
+ currentCursor == 0 && includeMutableComponent ? searchCallback.proceed(currentTuple) : true;
btreeTuple.reset(rtreeCursors[currentCursor].getTuple());
boolean killerTupleFound = false;
for (int i = 0; i < currentCursor && !killerTupleFound; i++) {
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuplesSearchCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuplesSearchCursor.java
index 7db65bd..05dc3ef 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuplesSearchCursor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuplesSearchCursor.java
@@ -177,7 +177,7 @@
// reconcile() and complete() can be added later after considering the semantics.
// Call proceed() to do necessary operations before returning this tuple.
- resultOfsearchCallBackProceed = searchCallback.proceed(diskRTreeTuple);
+ resultOfsearchCallBackProceed = true;
if (searchMemBTrees(diskRTreeTuple, numMemoryComponents)) {
// anti-matter tuple is NOT found
foundNext = true;