Fix for issue 127.
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeNSMInteriorFrame.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeNSMInteriorFrame.java
index 3f651df..cdaf144 100644
--- a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeNSMInteriorFrame.java
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeNSMInteriorFrame.java
@@ -228,10 +228,6 @@
             // On the left page, remove the highest key and make its child pointer
             // the rightmost child pointer.
             buf.putInt(tupleCountOff, tuplesToLeft);
-
-            // Compact both pages.
-            rightFrame.compact();
-            compact();
         }
         // Copy the split key to be inserted.
         // We must do so because setting the new split key will overwrite the
@@ -251,6 +247,9 @@
         buf.putInt(rightLeafOff, buf.getInt(getLeftChildPageOff(frameTuple)));
         buf.putInt(tupleCountOff, tuplesToLeft - 1);
 
+        // Compact both pages.
+        rightFrame.compact();
+        compact();
         // Insert the saved split key.
         int targetTupleIndex;
         // it's safe to catch this exception since it will have been caught before reaching here