[ASTERIXDB-2266][TX] Set Max Txn Log Record Size

- user model changes: no
- storage format changes: no
- interface changes: no

Details:
- Prevent log records that exceed the max
  log file size from being logged to avoid
  breaking recovery logic.

Change-Id: Ia9d353369c84aa6a5b364ebaef1083a423e54856
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2325
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
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 c226886..00c6c13 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
@@ -61,16 +61,11 @@
 
 public class LogManager implements ILogManager, ILifeCycleComponent {
 
-    /*
-     * Constants
-     */
     private static final Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger();
     private static final long SMALLEST_LOG_FILE_ID = 0;
     private static final int INITIAL_LOG_SIZE = 0;
-    public static final boolean IS_DEBUG_MODE = false;// true
-    /*
-     * Finals
-     */
+    private static final boolean IS_DEBUG_MODE = false;
+
     private final ITransactionSubsystem txnSubsystem;
     private final LogManagerProperties logManagerProperties;
     private final int numLogPages;
@@ -82,9 +77,8 @@
     private final long logFileSize;
     private final int logPageSize;
     private final AtomicLong appendLSN;
-    /*
-     * Mutables
-     */
+    private final long maxLogRecordSize;
+
     private LinkedBlockingQueue<ILogBuffer> emptyQ;
     private LinkedBlockingQueue<ILogBuffer> flushQ;
     private LinkedBlockingQueue<ILogBuffer> stashQ;
@@ -100,6 +94,7 @@
         logManagerProperties =
                 new LogManagerProperties(this.txnSubsystem.getTransactionProperties(), this.txnSubsystem.getId());
         logFileSize = logManagerProperties.getLogPartitionSize();
+        maxLogRecordSize = logFileSize - 1;
         logPageSize = logManagerProperties.getLogPageSize();
         numLogPages = logManagerProperties.getNumLogPages();
         logDir = logManagerProperties.getLogDir();
@@ -193,6 +188,9 @@
     }
 
     private boolean fileHasSpace(int logSize) {
+        if (logSize > maxLogRecordSize) {
+            throw new ACIDException("Maximum log record size of (" + maxLogRecordSize + ") exceeded");
+        }
         /*
          * To eliminate the case where the modulo of the next appendLSN = 0 (the next
          * appendLSN = the first LSN of the next log file), we do not allow a log to be