Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBASE-28356 RegionServer Canary should use Scan just like Region Canary with option to enable Raw Scan #5676

Merged
merged 2 commits into from
Feb 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -649,14 +649,16 @@ static class RegionServerTask implements Callable<Void> {
private String serverName;
private RegionInfo region;
private RegionServerStdOutSink sink;
private Boolean rawScanEnabled;
private AtomicLong successes;

RegionServerTask(Connection connection, String serverName, RegionInfo region,
RegionServerStdOutSink sink, AtomicLong successes) {
RegionServerStdOutSink sink, Boolean rawScanEnabled, AtomicLong successes) {
this.connection = connection;
this.serverName = serverName;
this.region = region;
this.sink = sink;
this.rawScanEnabled = rawScanEnabled;
this.successes = successes;
}

Expand All @@ -681,22 +683,35 @@ public Void call() {
get = new Get(startKey);
get.setCacheBlocks(false);
get.setFilter(new FirstKeyOnlyFilter());
stopWatch.start();
table.get(get);
stopWatch.stop();
// Converting get object to scan to enable RAW SCAN.
// This will work for all the regions of the HBase tables except first region.
scan = new Scan(get);

} else {
scan = new Scan();
// In case of first region of the HBase Table, we do not have start-key for the region.
// For Region Canary, we only need scan a single row/cell in the region to make sure that
// region is accessible.
//
// When HBase table has more than 1 empty regions at start of the row-key space, Canary
// will create multiple scan object to find first available row in the table by scanning
// all the regions in sequence until it can find first available row.
//
// Since First region of the table doesn't have any start key, We should set End Key as
// stop row and set inclusive=false to limit scan to first region only.
scan.withStopRow(region.getEndKey(), false);
scan.setCacheBlocks(false);
scan.setFilter(new FirstKeyOnlyFilter());
scan.setCaching(1);
scan.setMaxResultSize(1L);
scan.setOneRowLimit();
stopWatch.start();
ResultScanner s = table.getScanner(scan);
s.next();
s.close();
stopWatch.stop();
}
scan.setRaw(rawScanEnabled);
stopWatch.start();
ResultScanner s = table.getScanner(scan);
s.next();
s.close();
stopWatch.stop();
successes.incrementAndGet();
sink.publishReadTiming(tableName.getNameAsString(), serverName, stopWatch.getTime());
} catch (TableNotFoundException tnfe) {
Expand Down Expand Up @@ -1757,13 +1772,16 @@ private ZookeeperStdOutSink getSink() {
* A monitor for regionserver mode
*/
private static class RegionServerMonitor extends Monitor {
private boolean rawScanEnabled;
private boolean allRegions;

public RegionServerMonitor(Connection connection, String[] monitorTargets, boolean useRegExp,
Sink sink, ExecutorService executor, boolean allRegions, boolean treatFailureAsError,
long allowedFailures) {
super(connection, monitorTargets, useRegExp, sink, executor, treatFailureAsError,
allowedFailures);
Configuration conf = connection.getConfiguration();
this.rawScanEnabled = conf.getBoolean(HConstants.HBASE_CANARY_READ_RAW_SCAN_KEY, false);
this.allRegions = allRegions;
}

Expand Down Expand Up @@ -1836,14 +1854,14 @@ private void monitorRegionServers(Map<String, List<RegionInfo>> rsAndRMap,
} else if (this.allRegions) {
for (RegionInfo region : entry.getValue()) {
tasks.add(new RegionServerTask(this.connection, serverName, region, regionServerSink,
successes));
this.rawScanEnabled, successes));
}
} else {
// random select a region if flag not set
RegionInfo region =
entry.getValue().get(ThreadLocalRandom.current().nextInt(entry.getValue().size()));
tasks.add(
new RegionServerTask(this.connection, serverName, region, regionServerSink, successes));
tasks.add(new RegionServerTask(this.connection, serverName, region, regionServerSink,
this.rawScanEnabled, successes));
}
}
try {
Expand Down