You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by mh...@apache.org on 2018/12/15 09:50:16 UTC

asterixdb git commit: [ASTERIXDB-2497][TX] Ensure Log Record Flush LSN is Set

Repository: asterixdb
Updated Branches:
  refs/heads/master 376cde426 -> 440e3a56b


[ASTERIXDB-2497][TX] Ensure Log Record Flush LSN is Set

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

Details:
- Set the flush LSN of log records before giving it
  to the log flusher to avoid reading invalid value
  if the flush is completed before setting the LSN.
- Ensure log record LSN is thread-safe.
- Warn in case of a flush with LSN = 0.

Change-Id: Ifc605c2d794339a3dc5004b462eca50ec103c717
Reviewed-on: https://asterix-gerrit.ics.uci.edu/3087
Sonar-Qube: Jenkins <je...@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <je...@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Hubail <mh...@apache.org>
Reviewed-by: Till Westmann <ti...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/440e3a56
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/440e3a56
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/440e3a56

Branch: refs/heads/master
Commit: 440e3a56b6f7d888c07575a898b79fec8848e06a
Parents: 376cde4
Author: Murtadha Hubail <mh...@apache.org>
Authored: Thu Dec 13 20:42:46 2018 +0300
Committer: Murtadha Hubail <mh...@apache.org>
Committed: Sat Dec 15 01:49:35 2018 -0800

----------------------------------------------------------------------
 .../asterix/common/context/PrimaryIndexOperationTracker.java      | 3 +++
 .../java/org/apache/asterix/common/transactions/LogRecord.java    | 2 +-
 .../transaction/management/service/logging/LogManager.java        | 2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/440e3a56/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/PrimaryIndexOperationTracker.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/PrimaryIndexOperationTracker.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/PrimaryIndexOperationTracker.java
index a1d31d5..59e19ca 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/PrimaryIndexOperationTracker.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/PrimaryIndexOperationTracker.java
@@ -201,6 +201,9 @@ public class PrimaryIndexOperationTracker extends BaseOperationTracker implement
             }
             idGenerator.refresh();
             long flushLsn = logRecord.getLSN();
+            if (flushLsn == 0) {
+                LOGGER.warn("flushing an index with LSN 0. Flush log record: {}", logRecord::getLogRecordForDisplay);
+            }
             ILSMComponentId nextComponentId = idGenerator.getId();
             Map<String, Object> flushMap = new HashMap<>();
             flushMap.put(LSMIOOperationCallback.KEY_FLUSH_LOG_LSN, flushLsn);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/440e3a56/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/transactions/LogRecord.java
----------------------------------------------------------------------
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 0c3b21d..7a1079d 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
@@ -88,7 +88,7 @@ public class LogRecord implements ILogRecord {
     private final ILogMarkerCallback callback; // A callback for log mark operations
     private int PKFieldCnt;
     private ITransactionContext txnCtx;
-    private long LSN;
+    private volatile long LSN;
     private final AtomicBoolean isFlushed;
     private final PrimaryKeyTupleReference readPKValue;
     private final SimpleTupleReference readNewValue;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/440e3a56/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/logging/LogManager.java
----------------------------------------------------------------------
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 0a6dda9..a990379 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
@@ -187,10 +187,10 @@ public class LogManager implements ILogManager, ILifeCycleComponent {
         }
         final int logSize = logRecord.getLogSize();
         ensureSpace(logSize);
-        appendPage.append(logRecord, appendLSN.get());
         if (logRecord.getLogType() == LogType.FLUSH) {
             logRecord.setLSN(appendLSN.get());
         }
+        appendPage.append(logRecord, appendLSN.get());
         if (logRecord.isMarker()) {
             logRecord.logAppended(appendLSN.get());
         }