ASTERIXDB-1462: Remove previous LSN from txn log record

Change-Id: I32509ebe476e5993609f6fd73d2227a7d5219558
Reviewed-on: https://asterix-gerrit.ics.uci.edu/879
Reviewed-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: abdullah alamoudi <bamousaa@gmail.com>
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/transactions/ILogRecord.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/transactions/ILogRecord.java
index abc1211..3738cd1 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/transactions/ILogRecord.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/transactions/ILogRecord.java
@@ -34,7 +34,7 @@
 
     public static final int JOB_TERMINATE_LOG_SIZE = 14; //JOB_COMMIT or ABORT log type
     public static final int ENTITY_COMMIT_LOG_BASE_SIZE = 30;
-    public static final int UPDATE_LOG_BASE_SIZE = 59;
+    public static final int UPDATE_LOG_BASE_SIZE = 51;
     public static final int FLUSH_LOG_SIZE = 18;
     public static final int WAIT_LOG_SIZE = 14;
 
@@ -66,10 +66,6 @@
 
     public void setPKHashValue(int PKHashValue);
 
-    public long getPrevLSN();
-
-    public void setPrevLSN(long prevLsn);
-
     public long getResourceId();
 
     public void setResourceId(long resourceId);
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/transactions/LogRecord.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/transactions/LogRecord.java
index a16eef8..fd56913 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/transactions/LogRecord.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/transactions/LogRecord.java
@@ -80,7 +80,6 @@
     private int PKHashValue;
     private int PKValueSize;
     private ITupleReference PKValue;
-    private long prevLSN;
     private long resourceId;
     private int resourcePartition;
     private int logSize;
@@ -124,7 +123,6 @@
     private final static int TYPE_LEN = Byte.BYTES;
     public final static int PKHASH_LEN = Integer.BYTES;
     public final static int PKSZ_LEN = Integer.BYTES;
-    private final static int PRVLSN_LEN = Long.BYTES;
     private final static int RS_PARTITION_LEN = Integer.BYTES;
     private final static int RSID_LEN = Long.BYTES;
     private final static int LOGRCD_SZ_LEN = Integer.BYTES;
@@ -136,7 +134,7 @@
     private final static int ALL_RECORD_HEADER_LEN = LOG_SOURCE_LEN + TYPE_LEN + JobId.BYTES;
     private final static int ENTITYCOMMIT_UPDATE_HEADER_LEN = RS_PARTITION_LEN + DatasetId.BYTES + PKHASH_LEN
             + PKSZ_LEN;
-    private final static int UPDATE_LSN_HEADER = PRVLSN_LEN + RSID_LEN + LOGRCD_SZ_LEN;
+    private final static int UPDATE_LSN_HEADER = RSID_LEN + LOGRCD_SZ_LEN;
     private final static int UPDATE_BODY_HEADER = FLDCNT_LEN + NEWOP_LEN + NEWVALSZ_LEN;
     private final static int REMOTE_FLUSH_LOG_EXTRA_FIELDS_LEN = Long.BYTES + Integer.BYTES + Integer.BYTES;
 
@@ -155,7 +153,6 @@
             writePKValue(buffer);
         }
         if (logType == LogType.UPDATE) {
-            buffer.putLong(prevLSN);
             buffer.putLong(resourceId);
             buffer.putInt(logSize);
             buffer.putInt(fieldCnt);
@@ -305,7 +302,6 @@
                 if (buffer.remaining() < UPDATE_LSN_HEADER + UPDATE_BODY_HEADER) {
                     return RecordReadStatus.TRUNCATED;
                 }
-                prevLSN = buffer.getLong();
                 resourceId = buffer.getLong();
                 logSize = buffer.getInt();
                 fieldCnt = buffer.getInt();
@@ -444,7 +440,6 @@
             builder.append(" PKSize: ").append(PKValueSize);
         }
         if (logType == LogType.UPDATE) {
-            builder.append(" PrevLSN : ").append(prevLSN);
             builder.append(" ResourceId : ").append(resourceId);
         }
         return builder.toString();
@@ -525,16 +520,6 @@
     }
 
     @Override
-    public long getPrevLSN() {
-        return prevLSN;
-    }
-
-    @Override
-    public void setPrevLSN(long prevLSN) {
-        this.prevLSN = prevLSN;
-    }
-
-    @Override
     public long getResourceId() {
         return resourceId;
     }
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 d5ad038..94d2a8c 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
@@ -142,10 +142,8 @@
     }
 
     protected synchronized void syncAppendToLogTail(ILogRecord logRecord) throws ACIDException {
-        ITransactionContext txnCtx = null;
-
         if (logRecord.getLogType() != LogType.FLUSH) {
-            txnCtx = logRecord.getTxnCtx();
+            ITransactionContext txnCtx = logRecord.getTxnCtx();
             if (txnCtx.getTxnState() == ITransactionManager.ABORTED && logRecord.getLogType() != LogType.ABORT) {
                 throw new ACIDException(
                         "Aborted job(" + txnCtx.getJobId() + ") tried to write non-abort type log record.");
@@ -169,9 +167,6 @@
                 getAndInitNewPage();
             }
         }
-        if (logRecord.getLogType() == LogType.UPDATE) {
-            logRecord.setPrevLSN(txnCtx.getLastLSN());
-        }
         appendPage.append(logRecord, appendLSN.get());
 
         if (logRecord.getLogType() == LogType.FLUSH) {
diff --git a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/logging/LogManagerWithReplication.java b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/logging/LogManagerWithReplication.java
index 951bbbd..cacd036 100644
--- a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/logging/LogManagerWithReplication.java
+++ b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/logging/LogManagerWithReplication.java
@@ -90,15 +90,11 @@
 
     @Override
     protected synchronized void syncAppendToLogTail(ILogRecord logRecord) throws ACIDException {
-        ITransactionContext txnCtx = null;
-
-        if (logRecord.getLogSource() == LogSource.LOCAL) {
-            if (logRecord.getLogType() != LogType.FLUSH) {
-                txnCtx = logRecord.getTxnCtx();
-                if (txnCtx.getTxnState() == ITransactionManager.ABORTED && logRecord.getLogType() != LogType.ABORT) {
-                    throw new ACIDException(
-                            "Aborted job(" + txnCtx.getJobId() + ") tried to write non-abort type log record.");
-                }
+        if (logRecord.getLogSource() == LogSource.LOCAL && logRecord.getLogType() != LogType.FLUSH) {
+            ITransactionContext txnCtx = logRecord.getTxnCtx();
+            if (txnCtx.getTxnState() == ITransactionManager.ABORTED && logRecord.getLogType() != LogType.ABORT) {
+                throw new ACIDException(
+                        "Aborted job(" + txnCtx.getJobId() + ") tried to write non-abort type log record.");
             }
         }
 
@@ -114,11 +110,6 @@
                 getAndInitNewPage();
             }
         }
-        if (logRecord.getLogSource() == LogSource.LOCAL) {
-            if (logRecord.getLogType() == LogType.UPDATE) {
-                logRecord.setPrevLSN(txnCtx.getLastLSN());
-            }
-        }
         appendPage.appendWithReplication(logRecord, appendLSN.get());
 
         if (logRecord.getLogType() == LogType.FLUSH) {