Fixed an issue where we throw an exception saying there is memory to activate an index although it is already open.
diff --git a/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/dataflow/IndexLifecycleManager.java b/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/dataflow/IndexLifecycleManager.java
index 1c8bd28..77b2ec3 100644
--- a/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/dataflow/IndexLifecycleManager.java
+++ b/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/dataflow/IndexLifecycleManager.java
@@ -90,14 +90,13 @@
                     + " since it does not exist.");
         }
 
-        long inMemorySize = info.index.getMemoryAllocationSize();
-        while (memoryUsed + inMemorySize > memoryBudget) {
-            if (!evictCandidateIndex()) {
-                throw new HyracksDataException("Cannot activate index since memory budget would be exceeded.");
-            }
-        }
-
         if (!info.isOpen) {
+            long inMemorySize = info.index.getMemoryAllocationSize();
+            while (memoryUsed + inMemorySize > memoryBudget) {
+                if (!evictCandidateIndex()) {
+                    throw new HyracksDataException("Cannot activate index since memory budget would be exceeded.");
+                }
+            }
             info.index.activate();
             info.isOpen = true;
             memoryUsed += inMemorySize;