Luo Chen has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/2157

Change subject: [WIP] Add check for component LSN
......................................................................

[WIP] Add check for component LSN

Change-Id: Iafa2f555960657579736adb52a27ab2278bb4533
---
M 
asterixdb/asterix-common/src/main/java/org/apache/asterix/common/ioopcallbacks/AbstractLSMIOOperationCallback.java
1 file changed, 8 insertions(+), 0 deletions(-)


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

diff --git 
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/ioopcallbacks/AbstractLSMIOOperationCallback.java
 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/ioopcallbacks/AbstractLSMIOOperationCallback.java
index e445fe4..97ca015 100644
--- 
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/ioopcallbacks/AbstractLSMIOOperationCallback.java
+++ 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/ioopcallbacks/AbstractLSMIOOperationCallback.java
@@ -20,6 +20,7 @@
 package org.apache.asterix.common.ioopcallbacks;
 
 import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.data.std.primitive.LongPointable;
@@ -55,6 +56,8 @@
     protected int writeIndex;
 
     protected final ILSMComponentIdGenerator idGenerator;
+
+    protected AtomicLong previousLSN = new AtomicLong(0);
 
     public AbstractLSMIOOperationCallback(ILSMIndex lsmIndex, 
ILSMComponentIdGenerator idGenerator) {
         this.lsmIndex = lsmIndex;
@@ -188,6 +191,11 @@
             // Flush operation of an LSM index are executed sequentially.
             synchronized (this) {
                 long lsn = mutableLastLSNs[readIndex];
+                if (lsn > 0 && lsn <= previousLSN.get()) {
+                    throw new IllegalStateException(lsmIndex + " receives 
non-increasing LSN. " + " previous LSN "
+                            + previousLSN + " new LSN: " + lsn);
+                }
+                previousLSN.set(lsn);
                 return lsn;
             }
         }

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/2157
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iafa2f555960657579736adb52a27ab2278bb4533
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Luo Chen <[email protected]>

Reply via email to