Make sure the validty bit in the metadata page is flushed to disk when marking a component to be valid.
diff --git a/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java b/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java
index 6ec8f9f..3d7512f 100644
--- a/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java
+++ b/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java
@@ -125,16 +125,25 @@
         try {
             metadataFrame.setPage(metadataPage);
             metadataFrame.setValid(true);
-
-            // Flush the single modified page to disk.
-            bufferCache.flushDirtyPage(metadataPage);
-
-            // Force modified metadata page to disk.
-            bufferCache.force(fileId, true);
         } finally {
             metadataPage.releaseWriteLatch(true);
             bufferCache.unpin(metadataPage);
         }
+
+        // WARNING: flushing the metadata page should be done after releasing the write latch; otherwise, the page 
+        // won't be flushed to disk because it won't be dirty until the write latch has been released.
+        metadataPage = bufferCache.tryPin(BufferedFileHandle.getDiskPageId(fileId, metadataPageId));
+        if (metadataPage != null) {
+            try {
+                // Flush the single modified page to disk.
+                bufferCache.flushDirtyPage(metadataPage);
+            } finally {
+                bufferCache.unpin(metadataPage);
+            }
+        }
+
+        // Force modified metadata page to disk.
+        bufferCache.force(fileId, true);
     }
 
     @Override