[NO ISSUE][STO] Keep track of flushing memory components
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
- Indicate a memory component is full only if it is a component
pending a flush.
Change-Id: I121d842f823f5a615bd3833f11370334ff28ad2e
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/9703
Reviewed-by: Murtadha Hubail <mhubail@apache.org>
Reviewed-by: Ali Alsuliman <ali.al.solaiman@gmail.com>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/GlobalVirtualBufferCache.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/GlobalVirtualBufferCache.java
index a51e13c..0bb9bd5 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/GlobalVirtualBufferCache.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/GlobalVirtualBufferCache.java
@@ -73,6 +73,7 @@
private final List<ILSMIndex> primaryIndexes = new ArrayList<>();
private final Set<ILSMIndex> flushingIndexes = Collections.synchronizedSet(new HashSet<>());
+ private final Set<ILSMMemoryComponent> flushingComponents = Collections.synchronizedSet(new HashSet<>());
private volatile int flushPtr;
private final int filteredMemoryComponentMaxNumPages;
@@ -164,6 +165,7 @@
@Override
public void flushed(ILSMMemoryComponent memoryComponent) throws HyracksDataException {
+ flushingComponents.remove(memoryComponent);
if (flushingIndexes.remove(memoryComponent.getLsmIndex())) {
LOGGER.info("Completed flushing {}.", memoryComponent.getIndex());
// After the flush operation is completed, we may have 2 cases:
@@ -208,8 +210,7 @@
@Override
public boolean isFull(ILSMMemoryComponent memoryComponent) {
- return flushingIndexes.contains(memoryComponent.getLsmIndex())
- || isFilteredMemoryComponentFull(memoryComponent);
+ return flushingComponents.contains(memoryComponent) || isFilteredMemoryComponentFull(memoryComponent);
}
private boolean isFilteredMemoryComponentFull(ILSMMemoryComponent memoryComponent) {
@@ -508,7 +509,6 @@
// future writers
memoryComponent.setUnwritable();
}
-
opTracker.setFlushOnExit(true);
opTracker.flushIfNeeded();
// If the flush cannot be scheduled at this time, then there must be active writers.
@@ -522,6 +522,7 @@
if ((flushable || opTracker.isFlushLogCreated()) && !isMetadataIndex(primaryIndex)) {
// global vbc cannot wait on metadata indexes because metadata indexes support full
// ACID transactions. Waiting on metadata indexes can introduce deadlocks.
+ flushingComponents.add(primaryIndex.getCurrentMemoryComponent());
return primaryIndex;
}
}