abdullah alamoudi has submitted this change and it was merged.

Change subject: [NO ISSUE][STO] Improve logging when failing to schedule a flush
......................................................................


[NO ISSUE][STO] Improve logging when failing to schedule a flush

- user model changes: no
- storage format changes: no
- interface changes: no

Details:
- Log partition info when failing to schedule a flush operation.
- Fix isCurrentMutableComponentEmpty() to consider the
  UNREADABLE_UNWRITABLE state.

Change-Id: I9bbc0be36633b896becc16d3eeddeef980db5802
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2662
Sonar-Qube: Jenkins <[email protected]>
Tested-by: Jenkins <[email protected]>
Contrib: Jenkins <[email protected]>
Reviewed-by: Murtadha Hubail <[email protected]>
Integration-Tests: Jenkins <[email protected]>
---
M 
asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/PrimaryIndexOperationTracker.java
M 
hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java
2 files changed, 19 insertions(+), 4 deletions(-)

Approvals:
  Anon. E. Moose #1000171: 
  Jenkins: Verified; No violations found; ; Verified
  Murtadha Hubail: Looks good to me, approved



diff --git 
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/PrimaryIndexOperationTracker.java
 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/PrimaryIndexOperationTracker.java
index 52c8962..0aa0d2b 100644
--- 
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/PrimaryIndexOperationTracker.java
+++ 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/PrimaryIndexOperationTracker.java
@@ -51,8 +51,11 @@
 import org.apache.hyracks.storage.am.lsm.common.impls.LSMComponentId;
 import org.apache.hyracks.storage.common.IModificationOperationCallback;
 import org.apache.hyracks.storage.common.ISearchOperationCallback;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 public class PrimaryIndexOperationTracker extends BaseOperationTracker 
implements IoOperationCompleteListener {
+    private static final Logger LOGGER = LogManager.getLogger();
     private final int partition;
     // Number of active operations on an ILSMIndex instance.
     private final AtomicInteger numActiveOperations;
@@ -113,22 +116,33 @@
             }
         }
 
+        ILSMIndex primaryLsmIndex = null;
         if (needsFlush || flushOnExit) {
             flushOnExit = false;
             // make the current mutable components READABLE_UNWRITABLE to stop 
coming modify operations from entering
             // them until the current flush is scheduled.
             LSMComponentId primaryId = null;
             //Double check that the primary index has been modified
+
             synchronized (this) {
                 if (numActiveOperations.get() > 0) {
                     throw new IllegalStateException(
                             "Can't request a flush on an index with active 
operations: " + numActiveOperations.get());
                 }
                 for (ILSMIndex lsmIndex : indexes) {
-                    if (lsmIndex.isPrimaryIndex() && 
lsmIndex.isCurrentMutableComponentEmpty()) {
-                        return;
+                    if (lsmIndex.isPrimaryIndex()) {
+                        if (lsmIndex.isCurrentMutableComponentEmpty()) {
+                            LOGGER.info("Primary index on dataset {} and 
partition {} is empty... skipping flush");
+                            return;
+                        }
+                        primaryLsmIndex = lsmIndex;
+                        break;
                     }
                 }
+            }
+            if (primaryLsmIndex == null) {
+                throw new IllegalStateException(
+                        "Primary index not found in dataset " + 
dsInfo.getDatasetID() + " and partition " + partition);
             }
             for (ILSMIndex lsmIndex : indexes) {
                 ILSMOperationTracker opTracker = 
lsmIndex.getOperationTracker();
@@ -148,7 +162,8 @@
                 }
             }
             if (primaryId == null) {
-                throw new IllegalStateException("Primary index not found in 
dataset " + dsInfo.getDatasetID());
+                throw new IllegalStateException("Primary index found in 
dataset " + dsInfo.getDatasetID()
+                        + " and partition " + partition + " and is modified 
but its component id is null");
             }
             LogRecord logRecord = new LogRecord();
             if (dsInfo.isDurable()) {
diff --git 
a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java
 
b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java
index c9fb328..377a218 100644
--- 
a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java
+++ 
b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java
@@ -675,7 +675,7 @@
             ILSMMemoryComponent cmc = getCurrentMemoryComponent();
             ComponentState state = cmc.getState();
             return state == ComponentState.READABLE_UNWRITABLE_FLUSHING || 
state == ComponentState.INACTIVE
-                    || !cmc.isModified();
+                    || state == ComponentState.UNREADABLE_UNWRITABLE || 
!cmc.isModified();
         }
     }
 

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/2662
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9bbc0be36633b896becc16d3eeddeef980db5802
Gerrit-PatchSet: 2
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: abdullah alamoudi <[email protected]>
Gerrit-Reviewer: Anon. E. Moose #1000171
Gerrit-Reviewer: Jenkins <[email protected]>
Gerrit-Reviewer: Murtadha Hubail <[email protected]>
Gerrit-Reviewer: abdullah alamoudi <[email protected]>

Reply via email to