>From Ritik Raj <[email protected]>:

Ritik Raj has uploaded this change for review. ( 
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/21148?usp=email )


Change subject: [NO ISSUE][LOG] Added log to describe the indexComponent
......................................................................

[NO ISSUE][LOG] Added log to describe the indexComponent

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

Ext-ref: MB-71382
Change-Id: I1a9ee484afac5c537d9f69fcdcf10cdefdfdbb9d
---
M 
hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/util/ComponentUtils.java
1 file changed, 56 insertions(+), 2 deletions(-)



  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb 
refs/changes/48/21148/1

diff --git 
a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/util/ComponentUtils.java
 
b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/util/ComponentUtils.java
index bfb0c3c..d6c326a 100644
--- 
a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/util/ComponentUtils.java
+++ 
b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/util/ComponentUtils.java
@@ -85,6 +85,10 @@
             ILSMMemoryComponent cmc = index.getCurrentMemoryComponent();
             if (cmc.isReadable()) {
                 index.getCurrentMemoryComponent().getMetadata().get(key, 
value);
+            } else {
+                LOGGER.debug(
+                        "{} lookup skipped unreadable mutable memory component 
{} (state={}, modified={}, writers={})",
+                        key, cmc, cmc.getState(), cmc.isModified(), 
cmc.getWriterCount());
             }
             if (value.getLength() == 0) {
                 // was not found in the in current mutable component, search 
in the other in-memory components
@@ -93,7 +97,8 @@
                     // was not found in all in-memory components, search in 
the disk components
                     fromDiskComponents(index, key, value);
                     if (value.getLength() == 0) {
-                        LOGGER.debug("{} was NOT found for index {}", key, 
index);
+                        LOGGER.debug("{} was NOT found in {}. lookup context: 
{}", key, index,
+                                describeIndexComponentsUnsafe(index));
                     }
                 }
             } else {
@@ -102,6 +107,12 @@
         }
     }

+    public static String describeIndexComponents(ILSMIndex index) {
+        synchronized (index.getOperationTracker()) {
+            return describeIndexComponentsUnsafe(index);
+        }
+    }
+
     /**
      * Put LSM metadata state into the index's current memory component.
      *
@@ -154,6 +165,48 @@
         }
     }

+    private static String describeIndexComponentsUnsafe(ILSMIndex index) {
+        StringBuilder sb = new StringBuilder();
+        List<ILSMMemoryComponent> memComponents = index.getMemoryComponents();
+        
sb.append("currentMutableIndex=").append(index.getCurrentMemoryComponentIndex());
+        sb.append(", memoryComponents=[");
+        for (int i = 0; i < memComponents.size(); i++) {
+            if (i > 0) {
+                sb.append(", ");
+            }
+            appendMemoryComponent(sb, i, 
index.getCurrentMemoryComponentIndex(), memComponents.get(i));
+        }
+        sb.append("]");
+        List<ILSMDiskComponent> diskComponents = index.getDiskComponents();
+        sb.append(", diskComponents=[");
+        for (int i = 0; i < diskComponents.size(); i++) {
+            if (i > 0) {
+                sb.append(", ");
+            }
+            appendDiskComponent(sb, diskComponents.get(i));
+        }
+        sb.append("]");
+        return sb.toString();
+    }
+
+    private static void appendMemoryComponent(StringBuilder sb, int 
componentIndex, int currentMutableIndex,
+            ILSMMemoryComponent component) {
+        sb.append("{index=").append(componentIndex);
+        if (componentIndex == currentMutableIndex) {
+            sb.append(", current=true");
+        }
+        sb.append(", state=").append(component.getState());
+        sb.append(", readable=").append(component.isReadable());
+        sb.append(", modified=").append(component.isModified());
+        sb.append(", writers=").append(component.getWriterCount());
+        sb.append(", component=").append(component).append('}');
+    }
+
+    private static void appendDiskComponent(StringBuilder sb, 
ILSMDiskComponent component) {
+        sb.append("{state=").append(component.getState());
+        sb.append(", component=").append(component).append('}');
+    }
+
     public static void markAsValid(ITreeIndex treeIndex, boolean forceToDisk, 
IPageWriteFailureCallback callback)
             throws HyracksDataException {
         int fileId = treeIndex.getFileId();
@@ -175,13 +228,14 @@
         // We need to return all pages to the buffer cache in case of a failure
         try {
             bufferCache.getCompressedPageWriter(treeIndex.getFileId()).abort();
-        } catch (IllegalStateException | NullPointerException ignored) {
+        } catch (IllegalStateException | NullPointerException e) {
             // Since we call this method in multiple places, it is possible 
that the writer
             // is not in the State.WRITABLE, which would throw an 
IllegalStateException.
             // This means the writer has already written all the pages.
             //
             // We also catch NullPointerException in case the writer is not 
initialized.
             // Or if the compressed page writer is not applicable to this case
+            LOGGER.warn("Exception while getting compressed page writer", e);
         }
     }


--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/21148?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://asterix-gerrit.ics.uci.edu/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: asterixdb
Gerrit-Branch: lumina
Gerrit-Change-Id: I1a9ee484afac5c537d9f69fcdcf10cdefdfdbb9d
Gerrit-Change-Number: 21148
Gerrit-PatchSet: 1
Gerrit-Owner: Ritik Raj <[email protected]>

Reply via email to