From aedfd66b88f1d0a6a00345c5972e4423c5e82a19 Mon Sep 17 00:00:00 2001 From: "b.tian" Date: Wed, 17 Jan 2024 11:33:50 +0800 Subject: [PATCH] fix prewrite & commit log info to debug(#776) --- .../java/org/tikv/txn/TwoPhaseCommitter.java | 53 +++++++++++-------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/src/main/java/org/tikv/txn/TwoPhaseCommitter.java b/src/main/java/org/tikv/txn/TwoPhaseCommitter.java index 550b7de47a..b91a103b11 100644 --- a/src/main/java/org/tikv/txn/TwoPhaseCommitter.java +++ b/src/main/java/org/tikv/txn/TwoPhaseCommitter.java @@ -227,8 +227,9 @@ public class TwoPhaseCommitter implements AutoCloseable { this.doCommitPrimaryKeyWithRetry(backOffer, key, commitTs); } } - - LOG.info("commit primary key {} successfully", KeyUtils.formatBytes(key)); + if (commitResult.isSuccess() && LOG.isDebugEnabled()) { + LOG.debug("commit primary key {} successfully", KeyUtils.formatBytes(key)); + } } /** @@ -397,11 +398,13 @@ public class TwoPhaseCommitter implements AutoCloseable { BatchKeys batchKeys, Map mutations) throws TiBatchWriteException { - LOG.debug( - "start prewrite secondary key, row={}, size={}KB, regionId={}", - batchKeys.getKeys().size(), - batchKeys.getSizeInKB(), - batchKeys.getRegion().getId()); + if (LOG.isDebugEnabled()) { + LOG.debug( + "start prewrite secondary key, row={}, size={}KB, regionId={}", + batchKeys.getKeys().size(), + batchKeys.getSizeInKB(), + batchKeys.getRegion().getId()); + } List keyList = batchKeys.getKeys(); int batchSize = keyList.size(); @@ -445,11 +448,13 @@ public class TwoPhaseCommitter implements AutoCloseable { throw new TiBatchWriteException(errorMsg, e); } } - LOG.debug( - "prewrite secondary key successfully, row={}, size={}KB, regionId={}", - batchKeys.getKeys().size(), - batchKeys.getSizeInKB(), - batchKeys.getRegion().getId()); + if (LOG.isDebugEnabled()) { + LOG.debug( + "prewrite secondary key successfully, row={}, size={}KB, regionId={}", + batchKeys.getKeys().size(), + batchKeys.getSizeInKB(), + batchKeys.getRegion().getId()); + } } private void appendBatchBySize( @@ -592,11 +597,13 @@ public class TwoPhaseCommitter implements AutoCloseable { private void doCommitSecondaryKeySingleBatchWithRetry( BackOffer backOffer, BatchKeys batchKeys, long commitTs) throws TiBatchWriteException { - LOG.info( - "start commit secondary key, row={}, size={}KB, regionId={}", - batchKeys.getKeys().size(), - batchKeys.getSizeInKB(), - batchKeys.getRegion().getId()); + if (LOG.isDebugEnabled()) { + LOG.debug( + "start commit secondary key, row={}, size={}KB, regionId={}", + batchKeys.getKeys().size(), + batchKeys.getSizeInKB(), + batchKeys.getRegion().getId()); + } List keysCommit = batchKeys.getKeys(); ByteString[] keys = new ByteString[keysCommit.size()]; keysCommit.toArray(keys); @@ -612,11 +619,13 @@ public class TwoPhaseCommitter implements AutoCloseable { LOG.warn(error); throw new TiBatchWriteException("commit secondary key error", commitResult.getException()); } - LOG.info( - "commit {} rows successfully, size={}KB, regionId={}", - batchKeys.getKeys().size(), - batchKeys.getSizeInKB(), - batchKeys.getRegion().getId()); + if (commitResult.isSuccess() && LOG.isDebugEnabled()) { + LOG.debug( + "commit {} rows successfully, size={}KB, regionId={}", + batchKeys.getKeys().size(), + batchKeys.getSizeInKB(), + batchKeys.getRegion().getId()); + } } private GroupKeyResult groupKeysByRegion(ByteString[] keys, int size, BackOffer backOffer)