Fixed a concurrency bug in the LSMBTree that allowed more than one concurrent merge (needed to use isMerging CAS properly).

git-svn-id: https://hyracks.googlecode.com/svn/branches/hyracks_lsm_tree@1086 123451ca-8445-de46-9d55-352943316053
diff --git a/hyracks-storage-am-lsm-btree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/btree/impls/LSMBTree.java b/hyracks-storage-am-lsm-btree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/btree/impls/LSMBTree.java
index 8266387..1881d2f 100644
--- a/hyracks-storage-am-lsm-btree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/btree/impls/LSMBTree.java
+++ b/hyracks-storage-am-lsm-btree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/btree/impls/LSMBTree.java
@@ -443,10 +443,9 @@
         if (LOGGER.isLoggable(Level.INFO)) {
             LOGGER.info("Merging LSM-BTree.");
         }
-        if (isMerging.get()) {
+        if (!isMerging.compareAndSet(false, true)) {
             throw new TreeIndexException("Merge already in progress in LSMBTree. Only one concurrent merge allowed.");
         }
-        isMerging.set(true);
         
         // Point to the current searcher ref count, so we can wait for it later
         // (after we swap the searcher ref count).