You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by st...@apache.org on 2021/02/24 06:38:53 UTC
[phoenix] branch 5.1 updated: PHOENIX-6388 Add sampled logging for
read repairs
This is an automated email from the ASF dual-hosted git repository.
stoty pushed a commit to branch 5.1
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/5.1 by this push:
new fdbbea7 PHOENIX-6388 Add sampled logging for read repairs
fdbbea7 is described below
commit fdbbea705ce2f9014bff6b6641744a6a6d8fbfa3
Author: Xinyi Yan <ya...@apache.org>
AuthorDate: Tue Feb 23 15:51:46 2021 -0800
PHOENIX-6388 Add sampled logging for read repairs
---
.../apache/phoenix/index/GlobalIndexChecker.java | 28 +++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/index/GlobalIndexChecker.java b/phoenix-core/src/main/java/org/apache/phoenix/index/GlobalIndexChecker.java
index 9b2bd37..75775fa 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/index/GlobalIndexChecker.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/index/GlobalIndexChecker.java
@@ -28,6 +28,7 @@ import java.io.IOException;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;
+import java.util.Random;
import java.util.Optional;
import org.apache.hadoop.hbase.Cell;
@@ -96,6 +97,9 @@ import org.slf4j.LoggerFactory;
public class GlobalIndexChecker extends BaseScannerRegionObserver implements RegionCoprocessor{
private static final Logger LOG =
LoggerFactory.getLogger(GlobalIndexChecker.class);
+ private static final String REPAIR_LOGGING_PERCENT_ATTRIB = "phoenix.index.repair.logging.percent";
+ private static final double DEFAULT_REPAIR_LOGGING_PERCENT = 1;
+
private GlobalIndexCheckerSource metricsSource;
private CoprocessorEnvironment env;
@@ -140,6 +144,8 @@ public class GlobalIndexChecker extends BaseScannerRegionObserver implements Reg
private long pageSize = Long.MAX_VALUE;
private boolean restartScanDueToPageFilterRemoval = false;
private boolean hasMore;
+ private double loggingPercent;
+ private Random random;
private String indexName;
private long pageSizeMs;
@@ -171,6 +177,9 @@ public class GlobalIndexChecker extends BaseScannerRegionObserver implements Reg
"repairIndexRows: IndexMaintainer is not included in scan attributes for " +
region.getRegionInfo().getTable().getNameAsString());
}
+ loggingPercent = env.getConfiguration().getDouble(REPAIR_LOGGING_PERCENT_ATTRIB,
+ DEFAULT_REPAIR_LOGGING_PERCENT);
+ random = new Random(EnvironmentEdgeManager.currentTimeMillis());
pageSizeMs = getPageSizeMsForRegionScanner(scan);
}
@@ -586,18 +595,28 @@ public class GlobalIndexChecker extends BaseScannerRegionObserver implements Reg
byte[] rowKey = CellUtil.cloneRow(cell);
long ts = cellList.get(0).getTimestamp();
cellList.clear();
-
+ long repairTime;
try {
repairIndexRows(rowKey, ts, cellList);
+ repairTime = EnvironmentEdgeManager.currentTimeMillis() - repairStart;
metricsSource.incrementIndexRepairs(indexName);
metricsSource.updateUnverifiedIndexRowAge(indexName,
EnvironmentEdgeManager.currentTimeMillis() - ts);
metricsSource.updateIndexRepairTime(indexName,
EnvironmentEdgeManager.currentTimeMillis() - repairStart);
+ if (shouldLog()) {
+ LOG.info(String.format("Index row repair on region {} took {} ms.",
+ env.getRegionInfo().getRegionNameAsString(), repairTime));
+ }
} catch (IOException e) {
+ repairTime = EnvironmentEdgeManager.currentTimeMillis() - repairStart;
metricsSource.incrementIndexRepairFailures(indexName);
metricsSource.updateIndexRepairFailureTime(indexName,
EnvironmentEdgeManager.currentTimeMillis() - repairStart);
+ if (shouldLog()) {
+ LOG.warn("Index row repair failure on region {} took {} ms.",
+ env.getRegionInfo().getRegionNameAsString(), repairTime);
+ }
throw e;
}
@@ -608,6 +627,13 @@ public class GlobalIndexChecker extends BaseScannerRegionObserver implements Reg
return true;
}
}
+
+ private boolean shouldLog() {
+ if (loggingPercent == 0) {
+ return false;
+ }
+ return (random.nextDouble() <= (loggingPercent / 100.0d));
+ }
}
@Override