asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Murtadha Hubail (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: ASTERIXDB-1701: Fix log file boundry check
Date Fri, 21 Oct 2016 17:15:42 GMT
Murtadha Hubail has submitted this change and it was merged.

Change subject: ASTERIXDB-1701: Fix log file boundry check
......................................................................


ASTERIXDB-1701: Fix log file boundry check

Change-Id: I538a8b931f3d50a00b092f218887a9731d14e235
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1306
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Ian Maxon <imaxon@apache.org>
Reviewed-by: Michael Blow <mblow@apache.org>
---
M asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/logging/LogManager.java
M asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/logging/LogManagerWithReplication.java
2 files changed, 19 insertions(+), 14 deletions(-)

Approvals:
  Michael Blow: Looks good to me, approved
  Ian Maxon: Looks good to me, approved
  Jenkins: Verified; No violations found; Verified



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 7f74f52..7d61462 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
@@ -81,8 +81,8 @@
 
     public LogManager(TransactionSubsystem txnSubsystem) {
         this.txnSubsystem = txnSubsystem;
-        logManagerProperties =
-                new LogManagerProperties(this.txnSubsystem.getTransactionProperties(), this.txnSubsystem.getId());
+        logManagerProperties = new LogManagerProperties(this.txnSubsystem.getTransactionProperties(),
+                this.txnSubsystem.getId());
         logFileSize = logManagerProperties.getLogPartitionSize();
         logPageSize = logManagerProperties.getLogPageSize();
         numLogPages = logManagerProperties.getNumLogPages();
@@ -157,12 +157,12 @@
          * written at the last offset of the current file.
          */
         final int logSize = logRecord.getLogSize();
-        if (!appendPage.hasSpace(logSize)) {
-            if (getLogFileOffset(appendLSN.get()) + logSize >= logFileSize) {
-                prepareNextLogFile();
-            }
-            appendPage.isFull(true);
-            getAndInitNewPage(logSize);
+        // Make sure the log will not exceed the log file size
+        if (getLogFileOffset(appendLSN.get()) + logSize >= logFileSize) {
+            prepareNextLogFile();
+            prepareNextPage(logSize);
+        } else if (!appendPage.hasSpace(logSize)) {
+            prepareNextPage(logSize);
         }
         appendPage.append(logRecord, appendLSN.get());
 
@@ -175,6 +175,11 @@
         appendLSN.addAndGet(logSize);
     }
 
+    protected void prepareNextPage(int logSize) {
+        appendPage.isFull(true);
+        getAndInitNewPage(logSize);
+    }
+
     protected void getAndInitNewPage(int logSize) {
         if (logSize > logPageSize) {
             // for now, alloc a new buffer for each large page
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 f27c13f..c81225f 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
@@ -99,12 +99,12 @@
         }
 
         final int logRecordSize = logRecord.getLogSize();
-        if (!appendPage.hasSpace(logRecordSize)) {
-            if (getLogFileOffset(appendLSN.get()) + logRecordSize > logFileSize) {
-                prepareNextLogFile();
-            }
-            appendPage.isFull(true);
-            getAndInitNewPage(logRecordSize);
+        // Make sure the log will not exceed the log file size
+        if (getLogFileOffset(appendLSN.get()) + logRecordSize >= logFileSize) {
+            prepareNextLogFile();
+            prepareNextPage(logRecordSize);
+        } else if (!appendPage.hasSpace(logRecordSize)) {
+            prepareNextPage(logRecordSize);
         }
         appendPage.appendWithReplication(logRecord, appendLSN.get());
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I538a8b931f3d50a00b092f218887a9731d14e235
Gerrit-PatchSet: 2
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Murtadha Hubail <hubailmor@gmail.com>
Gerrit-Reviewer: Ian Maxon <imaxon@apache.org>
Gerrit-Reviewer: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Michael Blow <mblow@apache.org>
Gerrit-Reviewer: Murtadha Hubail <hubailmor@gmail.com>

Mime
View raw message