Fix log file EOF during recovery

Change-Id: If9adbdaea726dd21d15fc1287362375daf30bf16
Reviewed-on: https://asterix-gerrit.ics.uci.edu/878
Reviewed-by: abdullah alamoudi <bamousaa@gmail.com>
Reviewed-by: Michael Blow <michael.blow@couchbase.com>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/logging/LogManager.java b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/logging/LogManager.java
index be0435a..d5ad038 100644
--- a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/logging/LogManager.java
+++ b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/logging/LogManager.java
@@ -205,16 +205,13 @@
     protected void prepareNextLogFile() {
         //wait until all log records have been flushed in the current file
         synchronized (flushLSN) {
-            while (flushLSN.get() != appendLSN.get()) {
-                //notification will come from LogBuffer.internalFlush(.)
-                try {
+            try {
+                while (flushLSN.get() != appendLSN.get()) {
+                    //notification will come from LogBuffer.internalFlush(.)
                     flushLSN.wait();
-                } catch (InterruptedException e) {
-                    if (LOGGER.isLoggable(Level.SEVERE)) {
-                        LOGGER.severe("Preparing new log file was interrupted");
-                    }
-                    Thread.currentThread().interrupt();
                 }
+            } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
             }
         }
         //move appendLSN and flushLSN to the first LSN of the next log file
diff --git a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/logging/LogReader.java b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/logging/LogReader.java
index 1592aba..148aa7e 100644
--- a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/logging/LogReader.java
+++ b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/logging/LogReader.java
@@ -142,7 +142,7 @@
 
     private ReturnState waitForFlushOrReturnIfEOF() {
         synchronized (flushLSN) {
-            while (readLSN > flushLSN.get()) {
+            while (readLSN >= flushLSN.get()) {
                 if (isRecoveryMode) {
                     return ReturnState.EOF;
                 }
@@ -223,7 +223,7 @@
         readLSN = LSN;
         //wait for the log to be flushed if needed before trying to read it.
         synchronized (flushLSN) {
-            while (readLSN > flushLSN.get()) {
+            while (readLSN >= flushLSN.get()) {
                 try {
                     flushLSN.wait();
                 } catch (InterruptedException e) {