You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by al...@apache.org on 2021/04/07 12:47:58 UTC

[asterixdb] 17/25: [NO ISSUE][*DB][TXN] Avoid abort log on empty txn, reduce recovery logging

This is an automated email from the ASF dual-hosted git repository.

alsuliman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git

commit 104d46a8cd11dad14ed6ff8f6a074b1171afb09b
Author: Michael Blow <mb...@apache.org>
AuthorDate: Sun Apr 4 11:34:35 2021 -0400

    [NO ISSUE][*DB][TXN] Avoid abort log on empty txn, reduce recovery logging
    
    Change-Id: I91c01f34e38df7d2398e5383b5d39632e64f0e7f
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/10884
    Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Reviewed-by: Michael Blow <mb...@apache.org>
    Reviewed-by: Till Westmann <ti...@apache.org>
---
 .../org/apache/asterix/app/nc/RecoveryManager.java    | 19 ++++++++-----------
 .../service/transaction/TransactionManager.java       | 12 ++++++++----
 2 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/RecoveryManager.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/RecoveryManager.java
index 1461ef4..65cb36a 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/RecoveryManager.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/RecoveryManager.java
@@ -599,22 +599,19 @@ public class RecoveryManager implements IRecoveryManager, ILifeCycleComponent {
             throw new ACIDException(e);
         }
         long lastLSN = txnContext.getLastLSN();
-        if (LOGGER.isInfoEnabled()) {
-            LOGGER.info("rollbacking transaction log records from " + firstLSN + " to " + lastLSN);
-        }
+        boolean infoEnabled = LOGGER.isInfoEnabled();
         // check if the transaction actually wrote some logs.
         if (firstLSN == TransactionManagementConstants.LogManagerConstants.TERMINAL_LSN || firstLSN > lastLSN) {
-            if (LOGGER.isInfoEnabled()) {
-                LOGGER.info("no need to roll back as there were no operations by the txn " + txnContext.getTxnId());
+            if (infoEnabled) {
+                LOGGER.info("no need to rollback as there were no operations by " + txnContext.getTxnId());
             }
             return;
         }
-
-        // While reading log records from firstLsn to lastLsn, collect uncommitted txn's Lsns
-        if (LOGGER.isInfoEnabled()) {
-            LOGGER.info("collecting loser transaction's LSNs from " + firstLSN + " to " + lastLSN);
+        if (infoEnabled) {
+            LOGGER.info("rolling back transaction log records from " + firstLSN + " to " + lastLSN + " for "
+                    + txnContext.getTxnId());
         }
-
+        // While reading log records from firstLsn to lastLsn, collect uncommitted txn's Lsns
         Map<TxnEntityId, List<Long>> jobLoserEntity2LSNsMap = new HashMap<>();
         TxnEntityId tempKeyTxnEntityId = new TxnEntityId(-1, -1, -1, null, -1, false);
         int updateLogCount = 0;
@@ -722,7 +719,7 @@ public class RecoveryManager implements IRecoveryManager, ILifeCycleComponent {
                 }
             }
 
-            if (LOGGER.isInfoEnabled()) {
+            if (infoEnabled) {
                 LOGGER.info("undone loser transaction's effect");
                 LOGGER.info("[RecoveryManager's rollback log count] update/entityCommit/undo:" + updateLogCount + "/"
                         + entityCommitLogCount + "/" + undoCount);
diff --git a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/transaction/TransactionManager.java b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/transaction/TransactionManager.java
index c218dec..ee65962 100644
--- a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/transaction/TransactionManager.java
+++ b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/transaction/TransactionManager.java
@@ -18,6 +18,8 @@
  */
 package org.apache.asterix.transaction.management.service.transaction;
 
+import static org.apache.asterix.transaction.management.service.transaction.TransactionManagementConstants.LogManagerConstants.TERMINAL_LSN;
+
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.Map;
@@ -101,10 +103,12 @@ public class TransactionManager implements ITransactionManager, ILifeCycleCompon
         final ITransactionContext txnCtx = getTransactionContext(txnId);
         try {
             if (txnCtx.isWriteTxn()) {
-                LogRecord logRecord = new LogRecord();
-                TransactionUtil.formJobTerminateLogRecord(txnCtx, logRecord, false);
-                txnSubsystem.getLogManager().log(logRecord);
-                txnSubsystem.getCheckpointManager().secure(txnId);
+                if (txnCtx.getFirstLSN() != TERMINAL_LSN) {
+                    LogRecord logRecord = new LogRecord();
+                    TransactionUtil.formJobTerminateLogRecord(txnCtx, logRecord, false);
+                    txnSubsystem.getLogManager().log(logRecord);
+                    txnSubsystem.getCheckpointManager().secure(txnId);
+                }
                 txnSubsystem.getRecoveryManager().rollbackTransaction(txnCtx);
                 txnCtx.setTxnState(ITransactionManager.ABORTED);
             }